ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Update Palette After CastColorRange
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

w2m

USA
1990 Posts

Posted - Jan 19 2014 :  17:26:30  Show Profile  Reply
if you call:
ImageEnView1.Proc.CastColorRange(TColor2TRGB(iMinRGB), TColor2TRGB(iMaxRGB),
    TColor2TRGB(ColorBox1.Selected));

then call:
for i := 0 to ImageEnView1.IEBitmap.PaletteLength - 1 do
begin
  iIEBitmap.Fill(TRGB2TColor(ImageEnView1.IEBitmap.Palette[i]));
  ImageEnMView1.SetIEBitmapEx(ImageEnMView1.AppendImage, iIEBitmap);
  { Store the color value in the ImageTopText caption }
  ImageEnMView1.ImageTopText[i].Caption :=
    ColorToString(TRGB2TColor(ImageEnView1.IEBitmap.Palette[i]));
end;

the IEBitmap.PaletteLength is 0.

How do you refill or update the palette after calling CastColorRange?

UPDATE

I was able to answer my own question:
I figured out how to make sure the palette gets refreshed after casting the color range.

In order for ImageEn to be able to load palette colors (unique colors in the bitmap), the IEBitmap.PixelFormat must be ie8p or the palette is not loaded. When CastColorRange is executed (or for that matter any ImageEnProc method) ImageEn converts the pixelformat from ie8p to ie24bit, so when an attempt was made to refresh the palette colors after changing colors, the palette was empty, which explains why the color grid (ImageEnMView) did not refresh to show the new palette.

So... after executing CastColorRange we convert the pixel format from ie24RGB back to ie8p so the palette will be available once more so the colors can be refreshed.

Just remember that in order to work with palette colors with ImageEn all of this must be set:
1. ImageEnView1.LegacyBitmap := False;{ Do not use Windows Bitmaps }
2. ImageEnView1.IO.NativePixelFormat := True; { Load images in native format }
3. After executing CastColorRange (or any other imageen.proc) the bitmap is ie24RGB so convert it back to
ie8p so the pallet can be obtained:
if ImageEnView1.IEBitmap.PixelFormat <_ ie8p="ie8p" thenbr="thenbr"> ImageEnView1.IEBitmap.PixelFormat := ie8p;

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: