Board index » delphi » Please help with Delphi 3 and Resource Bitmaps

Please help with Delphi 3 and Resource Bitmaps

Hello,

IN A NUTSHELL,
why do multiple 24-bit converted to 8-bit Images look good when loaded
separately into TImage Components, but when stored in a *.RES file and
loaded at runtime they look poor?

DETAILS FOLLOW....
I have 4 different 24-bit color images saved as TIF files.  I would
like to convert these to 8-bit color BMP files and store them in my
application's *.RES file.  However, I'm having problems.

First, I use Photoshop 3.0 to convert the *.TIF files to 8-bit *.BMP
files.  I use an Adaptive Diffusion routine and limit the color
palette to about 24-32 colors for each image.  

Then, I change my system's color resolution to 8-bit and look at each
of the files to ensure good picture quaility.  Everything looks fine.

Using Delphi, I can create separate TImage components and using the
Object Inspector load each of the new 8-bit color images.  I arrive at
a form with 4 TImages, each with a different image, and everything
looks fine.  I believe that I was successful in converting the 24-bit
images and using a small enough number of colors for each picture so
that all images can share the system palette at once.

Now, I'd like to store these images in a *.RES file and load them at
run time.  Here's where it gets hairy.  

I use Delphi's ImageEdit to add the images to my applications *.RES
file.  I've tried two different methods for getting the images into
the *.RES file.  I can load the image using Paint or Photoshop and
copy it to the clipboard.  Or, I can use ImageEdit to load the Image
as a separate Bitmap and paste it to the clipboard.  Essentially, I
paste the images from the clipboard.  This maybe my first mistake; I'm
not sure.  Then, using ImageEdit, I create a new 8-bit color Bitmap
for my *.RES file and paste the image from the clipboard.  

This typically works fine.  However, as I repeat these steps for the
remaining images, their image quality gets worse and worse.  Until
finally they look terrible.  I assume this is because the system
palette is getting full, and each consecutive image must map its
colors to existing colors.

OK, so I can get around this by doing the above procedure for each
image only once per session of ImageEdit.  Namely, I load up
ImageEdit., load my *.RES file, add a new Bitmap, Save and Close.
Repeat these steps for all remaining images.

Well, this gets all the images in there alright.  And they seem to
look pretty good.  They're not as good as when loaded directly into a
TImage component.  

Using the LoadResourceName method for bitmaps, I load my images into
separate TImage componets and everything is less than perfect.
There's a good deal of pixelization and color mapping.  No good.

IN SUMMARY,  why do the Images all look good when loaded separately
into TImage Components, but when stored in a *.RES file and loaded at
runtime they look poor?

Thanks for reading this and for your help,
-Sterling Foiles
-Foundation Software

to email, remove the X's from:  XXssfoi...@texas.net

 

Re:Please help with Delphi 3 and Resource Bitmaps


Quote
fake_user@no_address.com wrote:

> Hello,

> IN A NUTSHELL,
> why do multiple 24-bit converted to 8-bit Images look good when loaded
> separately into TImage Components, but when stored in a *.RES file and
> loaded at runtime they look poor?

> DETAILS FOLLOW....
> I have 4 different 24-bit color images saved as TIF files.  I would
> like to convert these to 8-bit color BMP files and store them in my
> application's *.RES file.  However, I'm having problems.

> First, I use Photoshop 3.0 to convert the *.TIF files to 8-bit *.BMP
> files.  I use an Adaptive Diffusion routine and limit the color
> palette to about 24-32 colors for each image.

> Then, I change my system's color resolution to 8-bit and look at each
> of the files to ensure good picture quaility.  Everything looks fine.

> Using Delphi, I can create separate TImage components and using the
> Object Inspector load each of the new 8-bit color images.  I arrive at
> a form with 4 TImages, each with a different image, and everything
> looks fine.  I believe that I was successful in converting the 24-bit
> images and using a small enough number of colors for each picture so
> that all images can share the system palette at once.

> Now, I'd like to store these images in a *.RES file and load them at
> run time.  Here's where it gets hairy.

> I use Delphi's ImageEdit to add the images to my applications *.RES
> file.  I've tried two different methods for getting the images into
> the *.RES file.  I can load the image using Paint or Photoshop and
> copy it to the clipboard.  Or, I can use ImageEdit to load the Image
> as a separate Bitmap and paste it to the clipboard.  Essentially, I
> paste the images from the clipboard.  This maybe my first mistake; I'm
> not sure.  Then, using ImageEdit, I create a new 8-bit color Bitmap
> for my *.RES file and paste the image from the clipboard.

> This typically works fine.  However, as I repeat these steps for the
> remaining images, their image quality gets worse and worse.  Until
> finally they look terrible.  I assume this is because the system
> palette is getting full, and each consecutive image must map its
> colors to existing colors.

> OK, so I can get around this by doing the above procedure for each
> image only once per session of ImageEdit.  Namely, I load up
> ImageEdit., load my *.RES file, add a new Bitmap, Save and Close.
> Repeat these steps for all remaining images.

> Well, this gets all the images in there alright.  And they seem to
> look pretty good.  They're not as good as when loaded directly into a
> TImage component.

> Using the LoadResourceName method for bitmaps, I load my images into
> separate TImage componets and everything is less than perfect.
> There's a good deal of pixelization and color mapping.  No good.

> IN SUMMARY,  why do the Images all look good when loaded separately
> into TImage Components, but when stored in a *.RES file and loaded at
> runtime they look poor?

I usually embed resources as blobs using a resource script and then
restores the resource as a blob runtime. In your case, this would mean
restore the bitmap to a stream, and then use LoadFromStream to read the
bitmap into a TImage. This ensures the exact BMP file is stored, and
should give you the same appearance you get when adding the bitmaps
design-time.

Regards,

Erik.

--
Need a custom component? Late on a project? Could use an util?
DOS Device driver? A VxD? NT drivers or services?
Applications of any kind?
Low rates, fast delivery!

When responding to news postings, please CC a copy to my email address.
Thanks.
Erik Sperling Johansen <e...@info-pro.no>

Other Threads