Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Converting a JPG to BMP for use as Glyph

Posted on 2004-10-05
9
Medium Priority
?
2,100 Views
Last Modified: 2013-12-02
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
Comment
Question by:wildzero
9 Comments
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12225423
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
 
LVL 4

Accepted Solution

by:
Evarest earned 500 total points
ID: 12225612
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
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 12225844
smartsize .. you mean Antialiasing ? :)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 11

Expert Comment

by:calinutz
ID: 12226047
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
 
LVL 11

Expert Comment

by:calinutz
ID: 12226050
I forgot:

uses Jpeg;
0
 
LVL 17

Expert Comment

by:Wim ten Brink
ID: 12226728
@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
 
LVL 10

Author Comment

by:wildzero
ID: 12229108
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
 
LVL 1

Expert Comment

by:Bart_Thomas
ID: 12229379
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
 
LVL 34

Expert Comment

by:Slick812
ID: 12229522
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
In this second Micro Tutorial in the series,  viewers will learn more basic shortcuts and functions of Illustrator. In this tutorial you will learn about the eyedropper tool, zoom , ellipses and more.
In this Micro Tutorial viewers will learn the basic shortcuts and functions in InDesign.
Suggested Courses
Course of the Month15 days, 5 hours left to enroll

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question