There are no built-in functions to achieve this so we will build our own function.
type
TIEColorType = (ieGrayScale, // grayscale
ieBlackWhite, // black and white
ieColor, // colored
ieUnknown);
function GetColorType(AIEBitmap: TIEBitmap): TIEColorType;
begin
if AIEBitmap.Bitcount = 1 then
Result := ieBlackWhite
else if AIEBitmap.IsGrayScale then
Result := ieGrayScale
else if AIEBitmap.PaletteUsed > 2 then
Result := ieColor
else
Result := ieUnknown;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenPictureDialog1.Execute then
begin
ImageEnView1.IO.LoadFromFile(OpenPictureDialog1.FileName);
ImageEnView1.Update;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ImageEnView1.Proc.ConvertToGray;
ImageEnView1.Update;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ImageEnView1.Proc.ConvertToBWOrdered;
ImageEnView1.IEBitmap.Bitcount := 1;
ImageEnView1.Update;
end;
procedure TForm1.Button4Click(Sender: TObject);
var
ieColorType: TIEColorType;
iColor: string;
begin
ieColorType := GetColorType(ImageEnView1.IEBitmap);
case ieColorType of
ieGrayScale:
iColor := 'grayscale.';
ieBlackWhite:
iColor := 'black and white.';
ieColor:
iColor := 'colored.'
end;
MessageBox(0, PChar('The bitmap is ' + iColor), 'Color',
MB_ICONINFORMATION or MB_OK);
end;
This is only one way to achieve this so other options may work as well.
Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development