ImageEn, unit iexColorPalette |
|
LoadPaletteFromFile
Declaration
function LoadPaletteFromFile(const Filename: TFileName; Format: Integer = -1; Names: TStrings = nil): TIEArrayOfTRGB;
Description
Loads all colors in a palette file.
The following formats are supported:
◼JASC Palette (*..pal, *.psppalette)
◼Photoshop ACO (*.aco)
◼Photoshop ACT (*.act)
For
Format specify one of the following:
Const | Value | Description |
IECP_Fmt_Unknown | -1 | The file format will be guessed based on the file extension. If it is not recognized, then IECP_Fmt_JASC is assumed |
IECP_Fmt_JASC | 0 | File is loaded as a JASC Palette file |
IECP_Fmt_Photoshop_Act | 1 | File is loaded as a Photoshop ACT file |
IECP_Fmt_Photoshop_Aco | 2 | File is loaded as a Photoshop ACO file |
Photoshop ACO format may include names for each of the colors. If a valid TStringList is passed for the
Names parameter it will be filled with names.
Raises an exception if the file format is not recognized.
// Display all colors of a palette file in a TMemo
if OpenDialog1.Execute then
try
Memo1.Clear();
clrArray := LoadPaletteFromFile( OpenDialog1.Filename );
for I := Low( clrArray ) to High( clrArray ) do
Memo1.Lines.Add( ColorToString( TRGB2TColor( clrArray[ I ]));
except
ShowMessage( 'File format is unknown!' );
end;
// Show names and colors of a palette file
ssNames := TStringList.create();
clrArray := LoadPaletteFromFile( 'C:\PhotoshopPal.aco', -1, ssNames );
for I := Low( clrArray ) to High( clrArray ) do
begin
if ssNames[ I ] <> '' then
Memo1.Lines.Add( ssNames[ I ] + ': ' + ColorToString( TRGB2TColor( clrArray[ I ]))
else
Memo1.Lines.Add( ColorToString( TRGB2TColor( clrArray[ I ]));
end;
See Also
◼SavePaletteToFile◼LoadFromFile