Board index » delphi » Lost Color Depth loading ImageList from File

Lost Color Depth loading ImageList from File


2003-08-28 10:05:40 AM
delphi164
Hi,
I am loading ImageLists from individual BMP files using
MyImageList.FileLoad( rtBitMap, 'AImageName', cMaskColor );
When I select these into my Toolbar I note that the color depth of the
images has changed to 4 bit from 8 or 24bit.
My 256 color bitmaps look terrible at this lower color depth.
I cannot see any way to preserve the color depth of the original bitmaps.
The problem does not exist if I load the bitmap files into the ImageList at
design time Image List Editor.
Does anyone have any suggestions?
Regards
Andy Bell
 
 

Re:Lost Color Depth loading ImageList from File

if the list is empty and the first image you place in there happens to be a
4 bit image then the initial image will be created as a 4 bit and all added
images will be converted to 4 bit since the single master image was created
as a 4 bit.
that is my analogy of it.. :))
Andy Bell writes:
Quote
Hi,

I am loading ImageLists from individual BMP files using

MyImageList.FileLoad( rtBitMap, 'AImageName', cMaskColor );

When I select these into my Toolbar I note that the color depth of the
images has changed to 4 bit from 8 or 24bit.

My 256 color bitmaps look terrible at this lower color depth.

I cannot see any way to preserve the color depth of the original bitmaps.

The problem does not exist if I load the bitmap files into the ImageList at
design time Image List Editor.

Does anyone have any suggestions?

Regards
Andy Bell
 

Re:Lost Color Depth loading ImageList from File

Andy,
The Microsoft ImageList control does not support color palettes. 16 color
images generally work ok because most 16 color icons use the standard EGA
color palette, so when ImageList ignores the color palette nothing terrible
happens.
To load a 256 color image into an imagelist, you should load the bitmap into
a TBitmap first, change it is color depth to 24 bit (to eliminate the
palette) then assign or draw the bitmap into the imagelist.
Also, be sure you set the color depth of the ImageList before loading images
into it. Images are coerced into to the ImageList pixel format as they are
loaded, not the other way around.
-Danny
 

Re:Lost Color Depth loading ImageList from File

Thanks Danny - I will try this.
Did you write "Delphi Component Design"? I am still referring to this
book - Have you written any others?
Regards Andy
 

Re:Lost Color Depth loading ImageList from File

"Andy Bell" <XXXX@XXXXX.COM>writes
Quote
Thanks Danny - I will try this.

Did you write "Delphi Component Design"? I am still referring to this
book - Have you written any others?

Yes, I wrote DCD. I would love to write more, but who has the time? DCD took
18 months of nights and weekends.
-Danny