ImageEn, unit ieXCanvasUtils



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


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

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


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


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