• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2204
  • Last Modified:

Converting a JPG to BMP for use as Glyph

Hey there,

I have a bunch of JPG images, 32x32 and again in 48x48. What I did is get them in photoshop resize to 16x16 and save them as bmp, this sort of works but the images don't look right and have lots of 'white space' so I then had to convert them to 256 colors, use the Image Editor program with delphi to put in a 'pink' back ground. That gets rid of the white bits, but the images look REAL bad. I have some other bmp glyph's that look really good

So my question is, how can I make GOOD looking glyph's from good/sharp JPG images.
I can convert these images to anything else if needed.

Thanks
Nick
0
wildzero
Asked:
wildzero
1 Solution
 
Wim ten BrinkSelf-employed developerCommented:
JPG files often use a lossy compression, meaning that the image is slightly different from the original. (It lost some data.) The best thing to do is to convert them to bitmaps first, then resample or resize them as bitmaps, never saving them as JPG's anymore. Saving an image as JPG will reduce the image quality.
Also, resizing an image will also cause a quality loss, since again, you're throwing away data. In Paint Shop Pro, the're a smart resize option that tries to keep the quality as high as possible by merging pixels through some algorithm instead of deleting them. It gives a better result. This is referred as resampling.

In my experience, creating a glyph from scratch as bitmap tends to be a better quality than converted JPG files.
0
 
EvarestCommented:
Just don't use the standard Image Editor of Delphi. Use Photoshop or PaintShopPro instead, as Workshop_Alex suggested. Instead of resizing them right away, try to crop them as much as possible. Do this until you get a size that's some kind of multiple of 16x16 (24x24 for example is good enough).

Then resize using the Smart Size option. Now choose a color that's somewhat close to the border color of your image. This will be your background color.

Save the picture as BMP, and load them into a TImageList setting the correct background color (if not set already).

This should make better, but not the very best glyphs. Restrain from using the standard fuchsia color. If you fill a backgroundraster with Fuchsia, the Fuchsia color can "bleed" through to the top layers.

Another method, and the one I prefer is searching for free quality icons on the net. Also you can find a lot on your PC. I've bundled these and using a tool as Axialis Iconworkshop, I can easily extract the Icons i want. You can then save them as transparent PSD/PNG, and alter them accordinly in Photoshop. As Icons often contain a 16x16 version, and Axialis Workshop does a good job of resizing them, you'll get quite nice icons for your menus...

Of course, only royalty free icons should be used...

Kind regards,
Evarest
0
 
Lee_NoverCommented:
smartsize .. you mean Antialiasing ? :)
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
calinutzCommented:
procedure Jpeg2Bmp(const BmpFileName, JpgFileName: string);
var
  Bmp: TBitmap;
  Jpg: TJPEGImage;
begin
  Bmp := TBitmap.Create;
  Jpg := TJPEGImage.Create;
  try
    Jpg.LoadFromFile(JpgFileName);
    Bmp.Assign(Jpg);
    Bmp.SaveToFile(BmpFileName);
  finally
    Jpg.Free;
    Bmp.Free;
  end;
end;
0
 
calinutzCommented:
I forgot:

uses Jpeg;
0
 
Wim ten BrinkSelf-employed developerCommented:
@Lee_Nover, Anti-alias, resample, smart size... It's all basically the same principle. It makes the image smaller while trying to maintain the details by merging pixels instead of deleting them. However, the merging of the pixels depend a bit on the algorithm used to define the final quality. Some applications resample images better than others.

@calinutz, please reread the question. He did not ask for code to convert JPG's to bitmaps since this is pretty easy in the first place. It's actually not even a Delphi question, since this is image manipulation and choosing the right tools and applications for it. ;-)
0
 
wildzeroAuthor Commented:
Hmm ok I just realised I had an icon editing program, so I copy/pasted the image into that, resized to 16x16 but I still had the white space, when I load that bmp in as a Glyph it doesn't set that white as the background it just shows it, does that mean I have to color it as Fuchsia? How else can I get rid of the white?

You would have thought icons would be such a pain in the but :P

Thanks to all for the replys so far!
0
 
Bart_ThomasCommented:
Icons are indeed a pain in the ass. The size is too small for image-resizers. You end up with a mess after and you have to "correct" the result. Most important is to replace the background parts  by a background color (like Fuchsia). The image list will pick the color of one of the corners pixels as background color.
0
 
Slick812Commented:
as has been said, this may got nothing to do with delphi programming, I have made custom glyphs and icons from begining and had to resize them in a graphics image  editor, I have also taken existing images and icons and made 16x16 small icon images (bitmaps), and it had nothing to do with  delphi code, , I just had to use the graphics image editor to  "Clean Up" the 16x16 image with graphics editing methods, like use the pencil tool to replace a pixel here and there, or the Flood Fill tool to replace areas of color, , , , ,

 to get rid of the "White" you talk about, , , i would get the pencil tool and draw over it

. . .  . But many times on resize (even a good resize by smart size) , , ,the new 16x16 image is a fuzzy blob (especially if there is much detail in the 32x32), and I would have to nearly redraw most of it to have it look at all like the 32x32
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now