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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Update Palette After CastColorRange

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
w2m Posted - Jan 19 2014 : 17:26:30
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