2.1.12.8 ocu_read_GIMP_palette


Description

read GIMP color palette file

Syntax

int ocu_read_GIMP_palette( LPCSTR lpcszFilename, int * pR, int * pG, int * pB, int nBuffSize )

Parameters

lpcszFilename
[input]pointer to the file to read
pR
[output] buffer to recevie the RGB values
pG
[output] buffer to recevie the RGB values
pB
[output] buffer to recevie the RGB values
nBuffSize
[input] RGB buffer size allocated

Return

number of entries read if success, otherwise the following error
-1: file not found
-2: file not a valid GIMP Palette

Examples

EX1

#define CE_MAX_COLORS 256
#define CE_MIN_COLORS 2
void read_palette(string strFileName = "d:\Spectral_11.gpl")
{
    int nR[CE_MAX_COLORS], nG[CE_MAX_COLORS], nB[CE_MAX_COLORS];
    int nColors = ocu_read_GIMP_palette(strFileName, nR, nG, nB, CE_MAX_COLORS);
    if( CE_MIN_COLORS <= nColors && nColors <= CE_MAX_COLORS )
    {
        Worksheet wks = Project.ActiveLayer();
        wks.SetSize(-1, 3);
        Dataset dsR, dsG, dsB;
        dsR.Attach(wks, 0); dsR.SetSize(nColors);
        dsG.Attach(wks, 1); dsG.SetSize(nColors);
        dsB.Attach(wks, 2); dsB.SetSize(nColors);
        for( int i = 0; i < nColors; i++ )
        {
            dsR[i] = nR[i];
            dsG[i] = nG[i];
            dsB[i] = nB[i];
        }
    }
}

Remark

See Also

Header to Included

ocu.h

Reference