Declaration
// Full color palette overload
function IEPromptForColor(var AColor : TColor; PosX: Integer = 0; PosY: Integer = 0): Boolean; overload;
// Select from palette overloads
function IEPromptForColor(var AColor : TColor; Palette: array of TRGB; NumCol: integer; PosX: Integer = 0; PosY: Integer = 0): Boolean; overload;
function IEPromptForColor(var AColor : TColor; Palette: array of TColor; NumCol: integer; PosX: Integer = 0; PosY: Integer = 0): Boolean; overload;
function IEPromptForColor(var AColor : TColor; Palette: PRGBROW; NumCol: integer; PosX: Integer = 0; PosY: Integer = 0): Boolean; overload;
Description
Display a color selection dialog so the user can choose a color. Result is false if user cancels out.
With first overload the standard VCL Color dialog is used allow selection from full color palette.
With remaining overloads, an ImageEn dialog is used allowing only choices from the specified palette (maximum of 256 colors). You can generate color palettes using
GenerateDicomColorPalette,
GenerateHuePalette,
GenerateColorLuminancePalette and
GenerateGradientPalette.
You can optionally specify a pop-up location. If it is not specified, the dialog will be centered on the screen.
The "Custom Colors" for the Full Color dialog are specified by
ColorDialogCustomColorsNote: To output a palette to an image, you can use:
IEDrawColorPalette | Demos\Other\ImageEn_Dialogs\ImageEn_Dialogs.dpr |
// Prompt user to specify a fill color for the current layer
var
aColor: TColor;
begin
aColor := ImageEnView1.CurrentLayer.FillColor;
if IEPromptForColor( aColor ) then
ImageEnView1.CurrentLayer.FillColor := aColor;
ImageEnView1.Update();
end;
// Select a color used in the image
if IEPromptForColor( aColor, ImageEnView1.IO.Params.ColorMap^, ImageEnView1.IO.Params.ColorMapCount ) then
Panel1.Color := aColor;
// Show the palette of the file "myfile.gif"
ImageEnView1.IO.LoadFromFile('C:\myfile.gif');
IEPromptForColor( aColor, ImageEnView1.IO.Params.ColorMap^, ImageEnView1.IO.Params.ColorMapCount );
// Let user choose a hue of green for ImageEnView background
const
Color_Count = 256;
var
pal: array of TRGB;
dd: double;
i: Integer;
aColor: TColor;
begin
SetLength( pal, Color_Count );
dd := 255 / ( Color_Count - 1 );
for i := 0 to Color_Count - 1 do
pal[ Color_Count - i - 1 ] := CreateRGB( 0, blimit( Round( i * dd )), 0 );
if IEPromptForColor( aColor, pal, Color_Count ) then
ImageEnView1.Background := aColor;
end;
// Show preview of Rainbow color palette
var
colorMap: TIEArrayOfTRGB;
aColor: TColor;
begin
colorMap := GenerateDicomColorPalette( iectRainbow );
IEPromptForColor( aColor, colorMap, Length( colorMap ));
end;
// Colorize the image based on the user's selection of a color
if IEPromptForColor( cl ) then
begin
ColorToHSV( cl, h, s, v );
ImageEnView1.Proc.Colorize( h, s, 1.0 );
end;
// User selected Red...
See Also
◼TImageEnPaletteDialog◼GenerateDicomColorPalette◼GenerateColorLuminancePalette◼GenerateHuePalette◼GenerateGradientPalette