ImageEn, unit imageenproc

TImageEnProc.CalcImagePalette

TImageEnProc.CalcImagePalette


Declaration

procedure CalcImagePalette(var Palette: array of TRGB; MaxCol: Integer);


Description

Fills the Palette array with the colors found in the current image.
Palette is the array to fill.
MaxCol is the size of Palette. If the image has more than MaxCol colors, the image is quantized to match the number of colors specified.

Note:
 If the image PixelFormat is not ie24RGB, it will be converted
 If the image contains more colors than MaxCol, a quantizer is used to reduce the number of colors (using the method specified by ColorReductionAlgorithm)
 You can output the palette as an image using IEDrawColorPalette, or show the palette to the user using IEPromptForColor
 To return a list of the most common colors in an image, use GetDominantColor


Demo

Demo  Demos\ImageEditing\EveryMethod\EveryMethod.dpr


Example

 

// Output 256 colors of the image
var
  MyColorMap256: array [0..255] of TRGB;
  bmp: TIEBitmap;
begin
  ImageEnView1.Proc.CalcImagePalette( MyColorMap256, 256 );
  bmp := TIEBitmap.Create();
  IEDrawColorPalette( bmp, MyColorMap256, 30, 30, 16 );
  bmp.Write( 'D:\Palette256.png' );
  bmp.Free;
end;

 


// Show 1000 colors of the image
var
  MyColorMap1000: array [0..999] of TRGB;
  aColor: TColors;
begin
  ImageEnView1.Proc.CalcImagePalette( MyColorMap1000, 1000 );
  IEPromptForColor( aColor, MyColorMap1000, 1000 );
end;


See Also

 CreateRGB
 TRGB2TColor
 TColor2TRGB
 IEDrawColorPalette
 IEPromptForColor