Using the Default Logical Palette

The easiest way to create a logical palette is with fg_defpal(), which creates a 256-color logical palette using Fastgraph's default colors. The fg_defpal() function has no parameters and returns a logical palette handle of type HPALETTE, or NULL (zero) if it could not create the logical palette. To activate the logical palette, pass the logical palette handle to fg_realize(). The following code, which typically appears in the program's WM_CREATE message handler after establishing a device context, illustrates this sequence:

C/C++:

hPal = fg_defpal();
fg_realize(hPal);

Delphi:

hPal := fg_defpal;
fg_realize(hPal);

Visual Basic:

hPal = fg_defpal()
Call fg_realize(hPal)

Before a program exits, it should delete the logical palette with the Windows API function DeleteObject(). A good place to do this is in the program's WM_DESTROY message handler:

C/C++ and Delphi:

DeleteObject(hPal);

Visual Basic programs do not need to delete the logical palette, as Visual Basic handles this task automatically.

As we just mentioned, fg_realize() activates a logical palette (this process is called realizing the logical palette, hence the function name). A program must of course realize a logical palette before using it, but it must also do this when its window becomes the active window. Programs should thus call fg_realize() in their WM_SETFOCUS message handler:

C/C++ and Delphi:

fg_realize(hPal);

Visual Basic:

Call fg_realize(hPal)

The default Fastgraph logical palette contains the Windows system colors in their default Windows positions (colors 0-9 and 246-255). The remaining 236 colors (colors 10 to 245) are a subset of the default colors used in DOS 256-color graphics modes, starting with the standard 16-color DOS color set (colors 10 to 25) and a coarse grayscale of increasing intensity (colors 26 to 29). The next 216 colors (30 to 245) contain three groups of 72 colors each, with the first group (30 to 101) at high intensity, the second group (102 to 173) at moderate intensity, and the third group (174 to 245) at low intensity. Each group consists of three ranges of decreasing saturation (increasing whiteness), with each range varying in hue from blue to red to green. This information is summarized in the following table.

colors 0 to 9: the first 10 Windows system colors

0

black

5

lavender

1

dark red

6

slate

2

dark green

7

light gray

3

light green

8

pale green

4

dark blue

9

pale blue

colors 10 to 25: the standard 16-color DOS color set

10

black

14

red

18

dark gray

22

light red

11

blue

15

magenta

19

light blue

23

light magenta

12

green

16

brown

20

light green

24

yellow

13

cyan

17

gray

21

light cyan

25

white

colors 26 to 29: coarse grayscale (darker to lighter)

colors 30 to 53: high saturation, high intensity colors

colors 54 to 77: moderate saturation, high intensity colors

colors 78 to 101: low saturation, high intensity colors

colors 102 to 125: high saturation, moderate intensity colors

colors 126 to 149: moderate saturation, moderate intensity colors

colors 150 to 173: low saturation, moderate intensity colors

colors 174 to 197: high saturation, low intensity colors

colors 198 to 221: moderate saturation, low intensity colors

colors 222 to 245: low saturation, low intensity colors

colors 246 to 255: the last 10 Windows system colors

246

off white

251

yellow

247

medium gray

252

bright blue

248

dark gray

253

magenta

249

bright red

254

cyan

250

bright green

255

white

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.