Palette Property


Applies to

THtmlViewer, TFrameViewer, and TFrameBrowser components

Declaration

property Palette: HPalette;

Description

In order to best display many images each of which may have its own palette, the THtmlViewer component normally color dithers each image to a compromise rainbow palette. The Palette property allows the user to access this palette or to change it.

A common reason for wishing to change the palette is when the user has complete control of all the images to be displayed and the images all use the same palette.

Usage Notes

The Palette property has no effect in modes other than 256 color mode.

Palettes are copied when read or written.

Example

Assume that all images will use a common palette. The following shows code in the form's OnCreate event handler which uses the palette from one of those images to change THtmlViewer's palette.

procedure TForm1.FormCreate(Sender: TObject);

var

Bitmap: TBitmap;

begin

Bitmap := TBitmap.Create;

{Load a bitmap that has the common palette}

Bitmap.LoadFromFile(ExtractFilePath(ParamStr(0))+'myimage.bmp');

{Replace the palette with the common palette}

Viewer.Palette := Bitmap.Palette;

Bitmap.Free;

{no need to dither the images now}

Viewer.Dither := False;

end;

See Also

Dither property