This method retrieves the palette information for a raster image

[C++Builder]   [ bool = ]imagekitcontrolname->GetPaletteFromImage(short * Red, const int Red_Size, short * Green, const int Green_Size, short * Blue, const int Blue_Size, unsigned ImageHandle)
[C++Builder]   [ bool = ]imagekitcontrolname->GetPaletteFromImage(short * Red, const int Red_Size, short * Green, const int Green_Size, short * Blue, const int Blue_Size)
[Delphi]   [ Boolean = ]imagekitcontrolname.GetPalette(var Red, Green, Blue: array of Smallint; ImageHandle THandle)
[Delphi]   [ Boolean = ]imagekitcontrolname.GetPalette(var Red, Green, Blue: array of Smallint)

Parameters

Name Explanation
Red Array of the retrieved red palette information
Green Array of the retrieved green palette information
Blue Array of the retrieved blue palette information
ImageHandle The image handle of the raster image

* In C++Builder, the -1 element is passed to Red_Size, Green_Size, Blue_Size

Return Value

Returns True if successful, otherwise returns False.

Explanation

When the ImageHandle parameter contains a valid image handle
The image data that the ImageHandle parameter refers to will be processed.

When using the method with no ImageHandle parameter or when the ImageHandle parameter contains 0
The image data determined by the LayerNo property will be processed. If the LayerNo property is -1 (the base image) then the image data referred to by the ImageHandle property will be processed. If the value of the LayerNo property is between 0 and 99 then the image data referred to by the Layer(LayerNo).ImageHandle property will be processed.

To find out how many items are in the various RGB arrays, please refer to the PalCount property. The PalCount property value is refreshed when ever an image handle is set into the ImageHandle property of the Layer(LayerNo).ImageHandle property. Use the GetImageType method to retrieve the PalCount property value.

Examples:

In C++Builder

    VImageKit1->LayerNo = -1;
    if (VImageKit1->PalCount < 1) return;
    short *r = new short[VImageKit1->PalCount];
    short *g = new short[VImageKit1->PalCount];
    short *b = new short[VImageKit1->PalCount];
    VImageKit1->GetPaletteFromImage(r, VImageKit1->PalCount – 1, g, VImageKit1->PalCount – 1, b, VImageKit1->PalCount - 1);
    // use the r,g,b arrays here
    VImageKit1->SetPaletteToImage(r, VImageKit1->PalCount – 1, g, VImageKit1->PalCount – 1, b, VImageKit1->PalCount - 1);
    delete[] r;
    delete[] g;
    delete[] b;

In Delphi:

    var
        r, g, b: array of Smallint;
    begin
        VImageKit1.LayerNo := -1;
        if VImageKit1.PalCount < 1 then Exit;
        SetLength(r, VImageKit1.PalCount);
        SetLength(g, VImageKit1.PalCount);
        SetLength(b, VImageKit1.PalCount);
        VImageKit1.GetPaletteFromImage(r, g, b);
        {use the r,g,b arrays here}
        VImageKit1.SetPaletteToImage(r, g, b);
    end;

Differences from ImageKit7/8/9 ActiveX

This method was named GetPalette in the ActiveX version

 

The ImageKit9 VCL is a product created by Newtone Corporation