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
 Getting the BitDepth (32, 24, 8, 4) after an Undo

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 - Jul 20 2012 : 06:26:31
One of the problems I have had for years is getting the bitdepth of a bitmap in ImageEnView when converting from 32-bit to 24-bit, 8-bit and 4-bit after an undo.

After an undo you can use if ImageEnView1.IEBitmap.HasAlphaChannel then iBitDepth := 32 so it it easy to know if the image is 32-bit. But if the image does not have an alphachannel after an undo, how can you get the bitdepth?

IEBitmap BitCount is always 24 after an undo if the image does not have an alphachannel so the following does not work:

if ImageEnView1.IEBitmap.HasAlphaChannel then begin
  iBitDepth := 32;
  ImageEnView1.IO.Params.BitsPerSample := 8;
  ImageEnView1.IO.Params.SamplesPerPixel := 4;
end
else
begin
  iBitDepth := ImageEnView1.IEBitmap.BitCount;
  if iBitDepth = 24 then
  begin
    ImageEnView1.IO.Params.BitsPerSample := 8;
    ImageEnView1.IO.Params.SamplesPerPixel := 3;
  end
  else if iBitDepth = 8 then
  begin
    ImageEnView1.IO.Params.BitsPerSample := 8;
    ImageEnView1.IO.Params.SamplesPerPixel := 1;
  end
  else if iBitDepth = 4 then
  begin
    ImageEnView1.IO.Params.BitsPerSample := 4;
    ImageEnView1.IO.Params.SamplesPerPixel := 1;
  end;
end;

The question is how to get the correct bitdepth of an image after an undo?

William Miller
5   L A T E S T    R E P L I E S    (Newest First)
fab Posted - Jul 21 2012 : 23:10:21
quote:
It is possible to get the bitdepth of 4-bit if using the default of ImageEnView.LegacyBitmap := true and ImageEnView.IO.NativePixelFormat := false?


Unfortunately no, because when LegacyBitmap=true and NativePixelFormat=false pixels formats can be only ie24RGB (pf24bit) or ie1g (pf1bit).
w2m Posted - Jul 21 2012 : 06:53:22
It is possible to get the bitdepth of 4-bit if using the default of ImageEnView.LegacyBitmap := true and ImageEnView.IO.NativePixelFormat := false?

The images are loaded with ImageEnView.IO.LoadFromFile();

I set 4-bit by:
ImageEnView.IO.Params.BitsPerSample := 4;
ImageEnView.IO.Params.SamplesPerPixel := 1;
ImageEnView.IO.Params.ICO_BitCount[cxPageControl1.ActivePageIndex] := 4;
if ImageEnView.HasAlphaChannel then
ImageEnView.RemoveAlphaChannel;


William Miller
fab Posted - Jul 21 2012 : 00:57:34
If the image has been loaded with following parameters...
ImageEnView.LegacyBitmap := false;
ImageEnView.IO.NativePixelFormat := true;

...then you can use PaletteUsed property of TIEBitmap:

ImageEnView1.IO.Params.BitsPerSample := trunc(log2( ImageEnView1.IEBitmap.PaletteUsed));

PaletteUsed returns number of colors used in the palette. So, if it is 16, then log2(16) = 4, that is 4 bits.
w2m Posted - Jul 20 2012 : 14:23:48
Thanks Fabrizio... Is there no way to determine 4-bit?
ImageEnView.IO.Params.BitsPerSample := 4;
ImageEnView.IO.Params.SamplesPerPixel := 1;

William Miller
fab Posted - Jul 20 2012 : 12:42:07
You could check ImageEnView1.IEBitmap.PixelFormat:

case ImageEnView1.PixelFormat of
  ie1g:
    begin
      ImageEnView1.IO.Params.BitsPerSample := 1;
      ImageEnView1.IO.Params.SamplesPerPixel := 1;
    end;
  ie8p, ie8g:
    begin
      ImageEnView1.IO.Params.BitsPerSample := 8;
      ImageEnView1.IO.Params.SamplesPerPixel := 1;
    end;
  ie16g:
    begin
      ImageEnView1.IO.Params.BitsPerSample := 16;
      ImageEnView1.IO.Params.SamplesPerPixel := 1;
    end;
  ie24RGB, ie32RGB, ieCIELab:
    begin
      ImageEnView1.IO.Params.BitsPerSample := 8;
      ImageEnView1.IO.Params.SamplesPerPixel := 3;
    end;
  ie32f:
    begin
      ImageEnView1.IO.Params.BitsPerSample := 32;
      ImageEnView1.IO.Params.SamplesPerPixel := 1;
    end;
  ieCMYK:
    begin
      ImageEnView1.IO.Params.BitsPerSample := 8;
      ImageEnView1.IO.Params.SamplesPerPixel := 4;
    end;
  ie48RGB:
    begin
      ImageEnView1.IO.Params.BitsPerSample := 16;
      ImageEnView1.IO.Params.SamplesPerPixel := 3;
    end;
end;
if ImageEnView1.IEBitmap.HasAlphaChannel then
  ImageEnView1.IO.Params.SamplesPerPixel  := ImageEnView1.IO.Params.SamplesPerPixel  + 1;