ImageEn, unit iexColorPalette

TIEColorPalette.AssignPalette

TIEColorPalette.AssignPalette


Declaration

// Color source array overloads
procedure AssignPalette(Palette: array of TColor; Append: Boolean = false); overload;
procedure AssignPalette(Palette: array of TRGB; Append: Boolean = false); overload;
procedure AssignPalette(Palette: TIEArrayOfTRGB; Append: Boolean = false); overload;

// Image source overloads (TIEBitmap, TBitmap, TImageEnView, etc)
Procedure AssignPalette(Source: TObject; Append: Boolean = false; UsedColorsOnly: Boolean = False); overload;


Description

Replace the current color set with one of the following sources:
 An array of TRGB or TColor values
 A TImageEnView or TImageEnVect
 A TImageEnProc
 A TIEBitmap or TBitmap
 A stringlist of color strings (same as setting Colors)

If Append = False, existing colors in the control are cleared.
With the image source overload, UsedColorsOnly controls whether all colors in the image palette are added, or only those actually used (visible in the image).


Examples

// ASSIGN THE PALETTE OF AN TIMAGEENVIEW IMAGE

// Don't use Windows Bitmaps
// Load images in native format
ImageEnView1.IO.NativePixelFormat := true;
ImageEnView1.IO.LoadFromFile( 'C:\Image.jpeg' );
// Convert to 8bit Palette for display
if ImageEnView1.IEBitmap.PixelFormat <> ie8p then
  ImageEnView1.IEBitmap.PixelFormat := ie8p;
IEColorPalette1.AssignPalette( ImageEnView1, False, True );

// ASSIGN A PALETTE FROM A DATABASE THAT CONTAINS R, G AND B COLUMNS
var
  aPalette: array of TRGB;
  i: integer;
begin
  i := 0;
  SetLength( aPalette, tblColorList.RecordCount );
  tblColorList.First;
  While not tblColorList.EOF do
  begin
    aPalette[ i ].R := tblColorListRed.AsInteger;
    aPalette[ i ].G := tblColorListGreen.AsInteger;
    aPalette[ i ].B := tblColorListBlue.AsInteger;
    inc( i );
    tblColorList.Next;
  end;
  IEColorPalette1.AssignPalette( aPalette );
end;

// ASSIGN A PALETTE FROM A FILE CONTAINING COLOR VALUES
var
  ssFile: TStringList;
begin
  ssFile := TStringList.Create;
  ssFile.LoadFromFile( 'D:\MyColors.txt' );
  IEColorPalette1.AssignPalette( ssFile );
  ssFile.Free;
end;

// ASSIGN A DICOM COLOR PALETTE
var
  colorMap: TIEArrayOfTRGB;
begin
  colorMap := GenerateDicomColorPalette( iectHotIron );
  ColorPalette1.AssignPalette( colorMap );
end;


See Also

 Palette
 Colors
 AddColor
 GenerateDicomColorPalette