ImageEn, unit ieXCanvasUtils

IEDrawColorPalette


Declaration

procedure IEDrawColorPalette(Dest: TIEBitmap; Colors: array of TRGB; CellWidth, CellHeight, HorzCount: Integer; Background: TColor = clWhite; CellBorder: TColor = clBlack; ColorCount: Integer = -1); overload;
procedure IEDrawColorPalette(Dest: TIEBitmap; Colors: array of TColor; CellWidth, CellHeight, HorzCount: Integer; Background: TColor = clWhite; CellBorder: TColor = clBlack; ColorCount: Integer = -1); overload;


Description

Draw an array of colors as a grid to a bitmap.



Parameter Description
Dest The TIEBitmap to output to. It must be created, but does not need to be sized
Colors The colors to output
CellWidth The width of each color cell
CellHeight The height of each color cell
HorzCount The number of cells to draw horizontally (vertical count will be calculated automatically)
Background The color of the background (if there is an odd number of cells that do not fill the entire image)
CellBorder The border color of each cell. You can specify clNone for no border
ColorCount The number of colors in our array (if -1, the array length is used)

Note: To display a palette to the user, you can use: IEPromptForColor


Example

// Export palette to an image file
bmp := TIEBitmap.Create;
IEDrawColorPalette( bmp, ColorPalette1.Palette, 30, 30, 16 );
bmp.Write( 'D:\palette.png' );
bmp.Free;


 

// 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;