Retrieving Logical Palette Colors

Fastgraph provides two functions, fg_getrgb() and fg_getdacs(), for retrieving colors from the active logical palette. The fg_getrgb() function retrieves the RGB components of the specified color. Its parameters are the same as fg_setrgb(), but the last three parameters must be passed by reference because they receive the requested color's RGB components. For example,

C/C++:

int red, green, blue;
fg_getrgb(10,&red,&green,&blue);

Delphi:

var
  red, green, blue : integer;
begin
  fg_getrgb(10,red,green,blue);

Visual Basic:

Dim red As Long, green As Long, blue As Long
Call fg_getrgb(10, red, green, blue)

would store the RGB components for color 10 in the variables red, green, and blue. Each color component will be between 0 and 255.

As you might expect, fg_getdacs() retrieves one or more consecutive colors from the active logical palette and uses the same parameters as fg_setdacs(). The following code will store the RGB components for the 236 non-system colors (colors 10 to 245) in the array RGBvalues:

C/C++:

char RGBvalues[236*3];
fg_getdacs(10,236,RGBvalues);

Delphi:

var
  RGBvalues : array [1..236*3] of byte;
begin
  fg_getdacs(10,236,RGBvalues);

Visual Basic:

Dim RGBvalues(236 * 3) As Byte
Call fg_getdacs(10, 236, RGBvalues(0))

As always, each color component will be between 0 and 255.

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.