Solved

Converting a JPG to BMP for use as Glyph

Posted on 2004-10-05
9
1,848 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
Comment Utility
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 125 total points
Comment Utility
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
Comment Utility
smartsize .. you mean Antialiasing ? :)
0
 
LVL 11

Expert Comment

by:calinutz
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 11

Expert Comment

by:calinutz
Comment Utility
I forgot:

uses Jpeg;
0
 
LVL 17

Expert Comment

by:Wim ten Brink
Comment Utility
@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
Comment Utility
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
Comment Utility
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 33

Expert Comment

by:Slick812
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Learn how to use the remote presentation tool in Prezi to allow you to harness the power of this cloud based presentation platform. You can show your presentation with a remote audience using this free tool.
It’s easy to embed any of your public Prezi presentations on your website or social network to share with others. Learn how simple it is in this tutorial.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now