Mirror

How to get the number of colours of a bitmap (Views: 701)


Problem/Question/Abstract:

How to get the number of colours of a bitmap

Answer:

{ ... }
if Image1.Picture.Graphic is TBitmap then
begin
  case Image1.Picture.Bitmap.PixelFormat of
    {Find color depth}
    pf1bit: pf := '.  Monochrome';
    pf4bit: pf := '.  16 Colors';
    pf8bit: pf := '.  256 Colors';
    pf15bit: pf := '.  32768 Colors';
    pf16bit: pf := '.  65536 Colors';
    pf24bit: pf := '.  16 Million Colors';
    pf32bit: pf := '.  Gazillions of Colors!';
  else
    pf := '.  Custom color scheme';
  end;
end;

<< Back to main page