Summary of Color QuickDraw
Pascal Summary
Constants
CONST
{checking for Color QuickDraw and its features}
gestaltQuickdrawVersion = 'qd '; {Gestalt selector for Color QuickDraw}
gestalt8BitQD = $100; {8-bit Color QD}
gestalt32BitQD = $200; {32-bit Color QD}
gestalt32BitQD11 = $210; {32-bit Color QDv1.1}
gestalt32BitQD12 = $220; {32-bit Color QDv1.2}
gestalt32BitQD13 = $230; {System 7: 32-bit Color QDv1.3}
gestaltQuickdrawFeatures = 'qdrw'; {Gestalt selector for Color }
{ QuickDraw features}
gestaltHasColor = 0; {Color QuickDraw is present}
gestaltHasDeepGWorlds = 1; {GWorlds deeper than 1 bit}
gestaltHasDirectPixMaps = 2; {PixMaps can be direct--16 or 32 bit}
gestaltHasGrayishTextOr = 3; {supports text mode grayishTextOr}
{source modes for color graphics ports}
srcCopy = 0; {determine how close the color of the source pixel is }
{ to black, and assign this relative amount of }
{ foreground color to the destination pixel; determine }
{ how close the color of the source pixel is to white, }
{ and assign this relative amount of background }
{ color to the destination pixel}
srcOr = 1; {determine how close the color of the source pixel is }
{ to black, and assign this relative amount of }
{ foreground color to the destination pixel}
srcXor = 2; {where source pixel is black, invert the destination }
{ pixel--for a colored destination pixel, use the }
{ complement of its color if the pixel is direct, }
{ invert its index if the pixel is indexed}
srcBic = 3; {determine how close the color of the source pixel is }
{ to black, and assign this relative amount of }
{ background color to the destination pixel}
notSrcCopy = 4; {determine how close the color of the source pixel is }
{ to black, and assign this relative amount of }
{ background color to the destination pixel; determine }
{ how close the color of the source pixel is to white, }
{ and assign this relative amount of foreground color }
{ to the destination pixel}
notSrcOr = 5; {determine how close the color of the source pixel is }
{ to white, and assign this relative amount of }
{ foreground color to the destination pixel}
notSrcXor = 6; {where source pixel is white, invert the destination }
{ pixel--for a colored destination pixel, use the }
{ complement of its color if the pixel is direct, }
{ invert its index if the pixel is indexed}
notSrcBic = 7; {determine how close the color of the source pixel is }
{ to white, and assign this relative amount of }
{ background color to the destination pixel}
{special text transfer mode}
grayishTextOr = 49;
{arithmetic transfer modes available in Color QuickDraw}
blend = 32; {replace destination pixel with a blend of the source }
{ and destination pixel colors; if the destination is }
{ a bitmap or 1-bit pixel map, revert to srcCopy mode}
addPin = 33; {replace destination pixel with the sum of the source }
{ and destination pixel colors--up to a maximum }
{ allowable value; if the destination is a bitmap or }
{ 1-bit pixel map, revert to srcBic mode}
addOver = 34; {replace destination pixel with the sum of the source }
{ and destination pixel colors--but if the value of }
{ the red, green, or blue component exceeds 65,536, }
{ then subtract 65,536 from that value; if the }
{ destination is a bitmap or 1-bit pixel map, revert }
{ to srcXor mode}
subPin = 35; {replace destination pixel with the difference of the }
{ source and destination pixel colors--but not less }
{ than a minimum allowable value; if the destination }
{ is a bitmap or 1-bit pixel map, revert to srcOr mode}
addMax = 37; {compare the source and destination pixels, and }
{ replace the destination pixel with the color }
{ containing the greater saturation of each of the RGB }
{ components; if the destination is a bitmap or }
{ 1-bit pixel map, revert to srcBic mode}
subOver = 38; {replace destination pixel with the difference of the }
{ source and destination pixel colors--but if the }
{ value of the red, green, or blue component is less }
{ than 0, add the negative result to 65,536; if the }
{ destination is a bitmap or 1-bit pixel map, revert }
{ to srcXor mode}
adMin = 39; {compare the source and destination pixels, and }
{ replace the destination pixel with the color }
{ containing the lesser saturation of each of the RGB }
{ components; if the destination is a bitmap or }
{ 1-bit pixel map, revert to srcOr mode}
{transparent mode constant}
transparent = 36; {replace the destination pixel with the source pixel }
{ if the source pixel isn't equal to the background }
{ color}
hilite = 50; {add to source or pattern mode for highlighting}
hiliteBit = 7; {flag bit in HiliteMode (lowMem flag)}
pHiliteBit = 0; {flag bit in HiliteMode used with BitClr procedure}
defQDColors = 127; {resource ID of 'clut' for default QDColors}
{pixel type}
RGBDirect = 16; {16 & 32 bits per pixel pixelType value}
{pmVersion values}
baseAddr32 = 4; {pixmap base address is 32-bit address}
Data Types
TYPE PixMap =
RECORD
baseAddr: Ptr; {pixel image}
rowBytes: Integer; {flags, and row width}
bounds: Rect; {boundary rectangle}
pmVersion: Integer; {PixMap record version number}
packType: Integer; {packing format}
packSize: LongInt; {size of data in packed state}
hRes: Fixed; {horizontal resolution (dpi)}
vRes: Fixed; {vertical resolution (dpi)}
pixelType: Integer; {format of pixel image}
pixelSize: Integer; {physical bits per pixel}
cmpCount: Integer; {logical components per pixel}
cmpSize: Integer; {logical bits per component}
planeBytes: LongInt; {offset to next plane}
pmTable: CTabHandle; {handle to color table for this image}
pmReserved: LongInt; {reserved for future expansion}
END;
CGrafPtr =\xDD^CGrafPort;
CGrafPort =
RECORD
device: Integer; {device ID for font selection}
portPixMap: PixMapHandle; {handle to PixMap record}
portVersion: Integer; {highest 2 bits always set}
grafVars: Handle; {handle to GrafVars record}
chExtra: Integer; {added width for nonspace characters}
pnLocHFrac: Integer; {pen fraction}
portRect: Rect; {port rectangle}
visRgn: RgnHandle; {visible region}
clipRgn: RgnHandle; {clipping region}
bkPixPat: PixPatHandle; {background pattern}
rgbFgColor: RGBColor; {requested foreground color}
rgbBkColor: RGBColor; {requested background color}
pnLoc: Point; {pen location}
pnSize: Point; {pen size}
pnMode: Integer; {pattern mode}
pnPixPat: PixPatHandle; {pen pattern}
fillPixPat: PixPatHandle; {fill pattern}
pnVis: Integer; {pen visibility}
txFont: Integer; {font number for text}
txFace: Style; {text's font style}
txMode: Integer; {source mode for text}
txSize: Integer; {font size for text}
spExtra: Fixed; {added width for space characters}
fgColor: LongInt; {actual foreground color}
bkColor: LongInt; {actual background color}
colrBit: Integer; {plane being drawn}
patStretch: Integer; {used internally}
picSave: Handle; {picture being saved, used internally}
rgnSave: Handle; {region being saved, used internally}
polySave: Handle; {polygon being saved, used internally}
grafProcs: CQDProcsPtr; {low-level drawing routines}
END;
RGBColor =
RECORD
red: Integer; {red\xDDcomponent}
green: Integer; {green\xDDcomponent}
blue: Integer; {blue\xDDcomponent}
END;
ColorSpec =
RECORD
value: Integer; {index or other value}
rgb: RGBColor; {true color}
END;
cSpecArray : ARRAY[0..0] OF ColorSpec;
CTabHandle =\xDD^CTabPtr;
CTabPtr =\xDD^ColorTable;
ColorTable =\xDD
RECORD
ctSeed: LongInt; {unique identifier from table}
ctFlags: Integer; {contains flags describing the ctTable field; }
{ clear for a PixMap record}
ctSize:\xDD Integer; {number\xDDof\xDDentries\xDDin\xDDthe next field minus 1}
ctTable: cSpecArray; {an array of ColorSpec records}
END;
MatchRec =
RECORD
red: Integer; {red component of seed}
green: Integer; {green component of seed}
blue: Integer; {blue component of seed}
matchData: LongInt; {value in matchData parameter of }
{ SeedCFill or CalcCMask}
END;
PixPatHandle = ^PixPatPtr;
PixPatPtr = ^PixPat;
PixPat =
RECORD
patType: Integer; {pattern type}
patMap: PixMapHandle; {PixMap record for pattern}
patData: Handle; {pixel image defining pattern}
patXData: Handle; {expanded pixel image}
patXValid: Integer; {flags for expanded pattern data}
patXMap: Handle; {handle to expanded pattern data}
pat1Data: Pattern; {bit pattern for a GrafPort record}
END;
CQDProcsPtr = ^CQDProcs
CQDProcs =
RECORD
textProc: Ptr; {text drawing}
lineProc: Ptr; {line drawing}
rectProc: Ptr; {rectangle drawing}
rRectProc: Ptr; {rounded rectangle drawing}
ovalProc: Ptr; {oval drawing}
arcProc: Ptr; {arc and wedge drawing}
polyProc: Ptr; {polygon drawing}
rgnProc: Ptr; {region drawing}
bitsProc: Ptr; {bit transfer}
commentProc: Ptr; {picture comment processing}
txMeasProc: Ptr; {text width measurement}
getPicProc: Ptr; {picture retrieval}
putPicProc: Ptr; {picture saving}
opcodeProc: Ptr; {reserved for future use}
newProc1: Ptr; {reserved for future use}
newProc2: Ptr; {reserved for future use}
newProc3: Ptr; {reserved for future use}
newProc4: Ptr; {reserved for future use}
newProc5: Ptr; {reserved for future use}
newProc6: Ptr; {reserved for future use}
END;
GrafVars =
RECORD
rgbOpColor: RGBColor; {color for addPin, subPin, and blend}
rgbHiliteColor: RGBColor; {color for highlighting}
pmFgColor: Handle; {palette handle for foreground color}
pmFgIndex: Integer; {index value for foreground}
pmBkColor: Handle; {palette handle for background color}
pmBkIndex: Integer; {index value for background}
pmFlags: Integer; {flags for Palette Manager}
END;
Color QuickDraw Routines
Opening and Closing Color Graphics Ports
PROCEDURE OpenCPort (port: CGrafPtr);
PROCEDURE InitCPort (port: CGrafPtr);
PROCEDURE CloseCPort (port: CGrafPtr);
Managing a Color Graphics Pen
PROCEDURE PenPixPat (ppat: PixPatHandle);
Changing the Background Pixel Pattern
PROCEDURE BackPixPat (ppat: PixPatHandle);
Drawing With Color QuickDraw Colors
PROCEDURE RGBForeColor (color: RGBColor);
PROCEDURE RGBBackColor (color: RGBColor);
PROCEDURE SetCPixel (h,v: Integer; cPix: RGBColor);
PROCEDURE FillCRect (r: Rect; ppat: PixPatHandle);
PROCEDURE FillCRoundRect (r: Rect; ovalWidth,ovalHeight: Integer;
ppat: PixPatHandle);
PROCEDURE FillCOval (r: Rect; ppat: PixPatHandle);
PROCEDURE FillCArc (r: Rect; startAngle,arcAngle: Integer;
ppat: PixPatHandle);
PROCEDURE FillCPoly (poly: PolyHandle; ppat: PixPatHandle);
PROCEDURE FillCRgn (rgn: RgnHandle; ppat: PixPatHandle);
PROCEDURE OpColor (color: RGBColor);
PROCEDURE HiliteColor (color: RGBColor);
Determining Current Colors and Best Intermediate Colors
PROCEDURE GetForeColor (VAR color: RGBColor);
PROCEDURE GetBackColor (VAR color: RGBColor);
PROCEDURE GetCPixel (h,v: Integer; VAR cPix: RGBColor);
FUNCTION GetGray (device: GDHandle; backGround: RGBColor;
VAR foreGround: RGBColor): Boolean;
Calculating Color Fills
PROCEDURE SeedCFill (srcBits,dstBits: BitMap;
srcRect,dstRect: Rect; seedH,seedV: Integer;
matchProc: ProcPtr; matchData: LongInt);
PROCEDURE CalcCMask (srcBits,dstBits: BitMap;
srcRect,dstRect: Rect; seedRGB: RGBColor;
matchProc: ProcPtr; matchData: LongInt);
Creating, Setting, and Disposing of Pixel Maps
{DisposePixMap is also spelled as DisposPixMap}
FUNCTION NewPixMap : PixMapHandle;
PROCEDURE CopyPixMap (srcPM,dstPM: PixMapHandle);
PROCEDURE SetPortPix (pm: PixMapHandle);
PROCEDURE DisposePixMap (pm: PixMapHandle);
Creating and Disposing of Pixel Patterns
{DisposePixPat is also spelled as DisposPixPat}
FUNCTION GetPixPat (patID: Integer): PixPatHandle;
FUNCTION NewPixPat : PixPatHandle;
PROCEDURE CopyPixPat (srcPP,dstPP: PixPatHandle);
PROCEDURE MakeRGBPat (ppat: PixPatHandle; myColor: RGBColor);
PROCEDURE DisposePixPat (ppat: PixPatHandle);
Creating and Disposing of Color Tables
{DisposeCTable is also spelled as DisposCTable}
FUNCTION GetCTable (ctID: Integer): CTabHandle;
PROCEDURE DisposeCTable (cTable: CTabHandle);
Retrieving Color QuickDraw Result Codes
FUNCTION QDError: Integer;
Customizing Color QuickDraw Operations
PROCEDURE SetStdCProcs (VAR cProcs: CQDProcs);
Reporting Data Structure Changes to QuickDraw
PROCEDURE CTabChanged (ctab: CTabHandle);
PROCEDURE PixPatChanged (ppat: PixPatHandle);
PROCEDURE PortChanged (port: GrafPtr);
PROCEDURE GDeviceChanged (gdh: GDHandle);
Application-Defined Routine
FUNCTION MyColorSearch (rgb: RGBColor; position: LongInt): Boolean;
C Summary
Constants
enum {
/* checking for Color QuickDraw and its features */
gestaltQuickdrawVersion = 'qd ', /* Gestalt selector for Color
QuickDraw */
gestalt8BitQD = 0x100, /* 8-bit Color QD */
gestalt32BitQD = 0x200, /* 32-bit Color QD */
gestalt32BitQD11 = 0x210, /* 32-bit Color QDv1.1 */
gestalt32BitQD12 = 0x220, /* 32-bit Color QDv1.2 */
gestalt32BitQD13 = 0x230, /* System 7: 32-bit Color QDv1.3 */
gestaltQuickdrawFeatures
= 'qdrw', /* Gestalt selector for Color QuickDraw
features */
gestaltHasColor = 0, /* Color QuickDraw is present */
gestaltHasDeepGWorlds = 1, /* GWorlds deeper than 1 bit */
gestaltHasDirectPixMaps = 2, /* PixMaps can be direct--16 or 32 bit */
gestaltHasGrayishTextOr = 3, /* supports text mode grayishTextOr */
/* source modes for color graphics ports */
srcCopy = 0, /* determine how close the color of the source pixel is
to black, and assign this relative amount of
foreground color to the destination pixel; determine
how close the color of the source pixel is to white,
and assign this relative amount of background color
to the destination pixel */
srcOr = 1, /* determine how close the color of the source pixel is
to black, and assign this relative amount of
foreground color to the destination pixel */
srcXor = 2, /* where source pixel is black, invert the destination
pixel--for a colored destination pixel, use the
complement of its color if the pixel is direct,
invert its index if the pixel is indexed */
srcBic = 3, /* determine how close the color of the source pixel is
to black, and assign this relative amount of
background color to the destination pixel */
notSrcCopy = 4, /* determine how close the color of the source pixel is
to black, and assign this relative amount of
background color to the destination pixel; determine
how close the color of the source pixel is to white,
and assign this relative amount of foreground color
to the destination pixel */
notSrcOr = 5, /* determine how close the color of the source pixel is
to white, and assign this relative amount of
foreground color to the destination pixel */
notSrcXor = 6, /* where source pixel is white, invert destination
pixel--for a colored destination pixel, use the
complement of its color if the pixel is direct,
invert its index if the pixel is indexed */
notSrcBic = 7, /* determine how close the color of the source pixel is
to white, and assign this relative amount of
background color to the destination pixel */
/* special text transfer mode */
grayishTextOr = 49,
/* arithmetic transfer modes available in Color QuickDraw */
blend = 32, /* replace destination pixel with a blend of the source
and destination pixel colors; if the destination is a
bitmap or 1-bit pixel map, revert to srcCopy mode */
addPin = 33, /* replace destination pixel with the sum of the source
and destination pixel colors--up to a maximum
allowable value; if the destination is a bitmap or
1-bit pixel map, revert to srcBic mode */
addOver = 34, /* replace destination pixel with the sum of the source
and destination pixel colors--but if the value of
the red, green, or blue component exceeds 65,536,
subtract 65,536 from that value; if the destination
is a bitmap or 1-bit pixel map, revert to srcXor
mode */
subPin = 35, /* replace destination pixel with the difference of the
source and destination pixel colors--but not less
than a minimum allowable value; if the destination is
a bitmap or 1-bit pixel map, revert to srcOr mode */
addMax = 37, /* compare the source and destination pixels, and
replace the destination pixel with the color
containing the greater saturation of each of the RGB
components; if the destination is a bitmap or 1-bit
pixel map, revert to srcBic mode */
subOver = 38, /* replace destination pixel with the difference of the
source and destination pixel colors--but if the value
of the red, green, or blue component is less than 0,
add the negative result to 65,536; if the destination
is a bitmap or 1-bit pixel map, revert to
srcXor mode */
adMin = 39, /* compare the source and destination pixels, and
replace the destination pixel with the color
containing the lesser saturation of each of the RGB
components; if the destination is a bitmap or 1-bit
pixel map, revert to srcOr mode */
/* transparent mode constant */
transparent = 36, /* replace the destination pixel with the source pixel
if the source pixel isn't equal to the background
color */
hilite = 50, /* add to source or pattern mode for highlighting */
hiliteBit = 7, /* flag bit in highlight mode (lowMem flag) */
pHiliteBit = 0, /* flag bit in highlight mode used with BitClr
procedure */
defQDColors = 127, /* resource ID of 'clut' for default QDColors */
/* pixel type */
RGBDirect = 16, /* 16 & 32 bits/pixel pixelType value */
/* pmVersion values */
baseAddr32 = 4, /* pixel map base address is 32-bit address */
};
Data Types
struct PixMap {
Ptr baseAddr; /* pixel image */
short rowBytes; /* flags, and row width */
Rect bounds; /* boundary rectangle */
short pmVersion; /* PixMap version number */
short packType; /* packing format */
long packSize; /* size of data in packed state */
Fixed hRes; /* horizontal resolution (dpi) */
Fixed vRes; /* vertical resolution (dpi) */
short pixelType; /* format of pixel image */
short pixelSize; /* physical bits per pixel */
short cmpCount; /* logical components per pixel */
short cmpSize; /* logical bits per component */
long planeBytes; /* offset to next plane */
CTabHandle pmTable; /* handle to the ColorTable struct */
long pmReserved; /* reserved for future expansion; must be 0 */
};
typedef struct PixMap PixMap;
typedef PixMap *PixMapPtr, **PixMapHandle;
typedef unsigned char PixelType;
struct CGrafPort {
short device; /* device ID for font selection */
PixMapHandle portPixMap; /* handle to PixMap struct */
short portVersion;/* highest 2 bits always set */
Handle grafVars; /* handle to a GrafVars struct */
short chExtra; /* added width for nonspace characters */
short pnLocHFrac; /* pen fraction */
Rect portRect; /* port rectangle */
RgnHandle visRgn; /* visible region */
RgnHandle clipRgn; /* clipping region */
PixPatHandle bkPixPat; /* background pattern */
RGBColor rgbFgColor; /* requested foreground color */
RGBColor rgbBkColor; /* requested background color */
Point pnLoc; /* pen location */
Point pnSize; /* pen size */
short pnMode; /* pattern mode */
PixPatHandle pnPixPat; /* pen pattern */
PixPatHandle fillPixPat; /* fill pattern */
short pnVis; /* pen visibility */
short txFont; /* font number for text */
Style txFace; /* text's font style */
char filler;
short txMode; /* source mode for text */
short txSize; /* font size for text */
Fixed spExtra; /* added width for space characters */
long fgColor; /* actual foreground color */
long bkColor; /* actual background color */
short colrBit; /* plane being drawn */
short patStretch; /* used internally */
Handle picSave; /* picture being saved, used internally */
Handle rgnSave; /* region being saved, used internally */
Handle polySave; /* polygon being saved, used internally */
CQDProcsPtr grafProcs; /* low-level drawing routines */
};
typedef struct CGrafPort CGrafPort;
typedef CGrafPort *CGrafPtr;
typedef CGrafPtr CWindowPtr;
struct RGBColor {
unsigned short red; /* magnitude of red component */
unsigned short green; /* magnitude of green component */
unsigned short blue; /* magnitude of blue component */
};
typedef struct RGBColor RGBColor;
struct ColorSpec {
short value; /* index or other value */
RGBColor rgb; /* true color */
};
typedef struct ColorSpec ColorSpec;
typedef ColorSpec *ColorSpecPtr;
typedef ColorSpec CSpecArray[1];
struct ColorTable {
long ctSeed; /* unique identifier for table */
short ctFlags; /* high bit: 0 = PixMap; 1 = device */
short ctSize; /* number of entries in next field */
CSpecArray ctTable; /* array[0..0] of ColorSpec records */
};
typedef struct ColorTable ColorTable;
typedef ColorTable *CTabPtr, **CTabHandle;
struct MatchRec {
unsigned short red; /* red component of seed */
unsigned short green; /* green component of seed */
unsigned short blue; /* blue component of seed */
long matchData; /* value in matchData parameter of
SeedCFill or CalcCMask */
};
typedef struct MatchRec MatchRec;
struct PixPat {
short patType; /* pattern type */
PixMapHandle patMap; /* PixMap structure for pattern */
Handle patData; /* pixel-image defining pattern */
Handle patXData; /* expanded pattern image */
short patXValid; /* for expanded pattern data */
Handle patXMap; /* handle to expanded pattern data */
Pattern pat1Data; /* a bit pattern for a GrafPort structure */
};
typedef struct PixPat PixPat;
typedef PixPat *PixPatPtr, **PixPatHandle;
struct CQDProcs {
Ptr textProc; /* text drawing */
Ptr lineProc; /* line drawing */
Ptr rectProc; /* rectangle drawing */
Ptr rRectProc; /* rounded rectangle drawing */
Ptr ovalProc; /* oval drawing */
Ptr arcProc; /* arc/wedge drawing */
Ptr polyProc; /* polygon drawing */
Ptr rgnProc; /* region drawing */
Ptr bitsProc; /* bit transfer */
Ptr commentProc; /* picture comment processing */
Ptr txMeasProc; /* text width measurement */
Ptr getPicProc; /* picture retrieval */
Ptr putPicProc; /* picture saving */
Ptr opcodeProc; /* reserved for future use */
Ptr newProc1; /* reserved for future use */
Ptr newProc2; /* reserved for future use */
Ptr newProc3; /* reserved for future use */
Ptr newProc4; /* reserved for future use */
Ptr newProc5; /* reserved for future use */
Ptr newProc6; /* reserved for future use */
};
typedef struct CQDProcs CQDProcs;
typedef CQDProcs *CQDProcsPtr;
struct GrafVars {
RGBColor rgbOpColor; /* color for addPin,subPin,and blend */
RGBColor rgbHiliteColor; /* color for highlighting */
Handle pmFgColor; /* palette handle for foreground color */
short pmFgIndex; /* index value for foreground */
Handle pmBkColor; /* palette handle for background color */
short pmBkIndex; /* index value for background */
short pmFlags; /* flags for Palette Manager */
};
typedef struct GrafVars GrafVars;
typedef GrafVars *GVarPtr, **GVarHandle;
Color QuickDraw Functions
Opening and Closing Color Graphics Ports
pascal void OpenCPort (CGrafPtr port);
pascal void InitCPort (CGrafPtr port);
pascal void CloseCPort (CGrafPtr port);
Managing a Color Graphics Pen
pascal void PenPixPat (PixPatHandle pp);
Changing the Background Pixel Pattern
pascal void BackPixPat (PixPatHandle pp);
Drawing With Color QuickDraw Colors
pascal void RGBForeColor (const RGBColor *color);
pascal void RGBBackColor (const RGBColor *color);
pascal void SetCPixel (short h, short v, const RGBColor *cPix);
pascal void FillCRect (const Rect *r, PixPatHandle pp);
pascal void FillCRoundRect (const Rect *r, short ovalWidth,
short ovalHeight, PixPatHandle pp);
pascal void FillCOval (const Rect *r, PixPatHandle pp);
pascal void FillCArc (const Rect *r, short startAngle,
short arcAngle, PixPatHandle pp);
pascal void FillCPoly (PolyHandle poly, PixPatHandle pp);
pascal void FillCRgn (RgnHandle rgn, PixPatHandle pp);
pascal void OpColor (const RGBColor *color);
pascal void HiliteColor (const RGBColor *color);
Determining Current Colors and Best Intermediate Colors
pascal void GetForeColor (RGBColor *color);
pascal void GetBackColor (RGBColor *color);
pascal void GetCPixel (short h, short v, RGBColor *cPix);
pascal Boolean GetGray (GDHandle device, const RGBColor *backGround,
RGBColor *foreGround);
Calculating Color Fills
pascal void SeedCFill (const BitMap *srcBits, const BitMap *dstBits,
const Rect *srcRect, const Rect *dstRect,
short seedH, short seedV,
ColorSearchProcPtr matchProc, long matchData);
pascal void CalcCMask (const BitMap *srcBits, const BitMap *dstBits,
const Rect *srcRect, const Rect *dstRect,
const RGBColor *seedRGB,
ColorSearchProcPtr matchProc, long matchData);
Creating, Setting, and Disposing of Pixel Maps
/* DisposePixMap is also spelled as DisposPixMap */
pascal PixMapHandle NewPixMap
(void);
pascal void CopyPixMap (PixMapHandle srcPM, PixMapHandle dstPM);
pascal void SetPortPix (PixMapHandle pm);
pascal void DisposePixMap (PixMapHandle pm);
Creating and Disposing of Pixel Patterns
/* DisposePixPat is also spelled as DisposPixPat */
pascal PixPatHandle GetPixPat
(short patID);
pascal PixPatHandle NewPixPat
(void);
pascal void CopyPixPat (PixPatHandle srcPP, PixPatHandle dstPP);
pascal void MakeRGBPat (PixPatHandle pp, const RGBColor *myColor);
pascal void DisposePixPat (PixPatHandle pp);
Creating and Disposing of Color Tables
/* DisposeCTable is also spelled as DisposCTable */
pascal CTabHandle GetCTable
(short ctID);
pascal void DisposeCTable (CTabHandle cTable);
Retrieving Color QuickDraw Result Codes
pascal short QDError (void);
Customizing Color QuickDraw Operations
pascal void SetStdCProcs (CQDProcs *procs);
Reporting Data Structure Changes to QuickDraw
pascal void CTabChanged (CTabHandle ctab);
pascal void PixPatChanged (PixPatHandle ppat);
pascal void PortChanged (GrafPtr port);
pascal void GDeviceChanged (GDHandle gdh);
Application-Defined Function
pascal Boolean MyColorSearch(rgb RGBColor, position LongInt);
Assembly-Language Summary
Data Structures
PixMap Data Structure
0 | pmBaseAddr | long | pixel image |
4 | pmRowBytes | word | flags, and row width |
6 | pmBounds | 8 bytes | boundary rectangle |
14 | pmVersion | word | PixMap version number |
16 | pmPackType | word | packing format |
18 | pmPackSize | long | size of data in packed state |
22 | pmHRes | long | horizontal resolution (dpi) |
26 | pmVRes | long | vertical resolution (dpi) |
30 | pmPixelType | word | format of pixel image |
32 | pmPixelSize | word | physical bits per pixel |
34 | pmCmpCount | word | logical components per pixel |
36 | pmCmpSize | word | logical bits per component |
38 | pmPlaneBytes | long | offset to next plane |
42 | pmTable | long | handle to next ColorTable record |
46 | pmReserved | long | reserved; must be 0 |
CGrafPort Data Structure
0 | device | short | device ID for font selection |
2 | portPixMap | long | handle to PixMap record |
6 | portVersion | short | highest 2 bits always set |
8 | grafVars | long | handle to GrafVars record |
12 | chExtra | short | added width for nonspace characters |
14 | pnLocHFrac | short | pen fraction |
16 | portRect | 8 bytes | port rectangle |
24 | visRgn | long | visible region |
28 | clipRgn | long | clipping region |
32 | bkPixPat | long | background pattern |
36 | rgbForeColor | 6 bytes | requested foreground color |
42 | rgbBackColor | 6 bytes | requested background color |
48 | pnLoc | long | pen location |
52 | pnSize | long | pen size |
56 | pnMode | word | pattern mode |
58 | pnPixPat | long | pen pattern |
62 | fillPixPat | long | fill pattern |
66 | pnVis | word | pen visibility |
68 | txFont | word | font number for text |
70 | txFace | word | text's font style |
72 | txMode | word | source mode for text |
74 | txSize | word | font size for text |
76 | spExtra | long | added width for space characters |
80 | fgColor | long | actual foreground color |
84 | bkColor | long | actual background color |
88 | colrBit | word | plane being drawn |
90 | patStretch | word | used internally |
92 | picSave | long | picture being saved, used internally |
96 | rgnSave | long | region being saved, used internally |
100 | polySave | long | polygon being saved, used internally |
104 | grafProcs | long | low-level drawing routines |
Relative Offsets of Additional Fields in a CGrafPort Record
portBits | portPixMap | long | handle to PixMap record |
portPixMap+4 | portVersion | word | highest 2 bits always set |
portVersion+2 | grafVars | long | handle to a GrafVars record |
grafVars+4 | chExtra | word | added width for nonspace characters |
chExtra+2 | pnLocHFrac | word | pen fraction |
bkPat | bkPixPat | long | background pattern |
bkPixPat+4 | rgbFgColor | 6 bytes | requested foreground color |
rgbFgColor+6 | rgbBkColor | 6 bytes | requested background color |
pnPat | pnPixPat | long | pen pattern |
pnPixPat+4 | fillPixPat | long | fill pattern |
RGBColor Data Structure
0 | red | short | magnitude of red component |
2 | green | short | magnitude of green component |
4 | blue | short | magnitude of blue component |
ColorSpec Data Structure
0 | value | short | index or other value |
2 | rgb | 6 bytes | true color |
ColorTable Data Structure
0 | ctSeed | long | unique identifier for table |
4 | transIndex | word | index of transparent pixel (obsolete) |
8 | ctFlags | word | high bit: 0 = pixel map; 1 = device |
10 | ctSize | word | number of entries in next field |
12 | ctTable | variable | array of ColorSpec records |
MatchRec Data Structure
0 | red | word | red component of seed |
2 | green | word | green component of seed |
4 | blue | word | blue component of seed |
6 | matchData | long | value in matchData parameter of SeedCFill or CalcCMask |
PixPat Data Structure
0 | patType | word | pattern type |
2 | patMap | long | handle to PixMap record for pattern |
6 | patData | long | pixel-image defining pattern |
10 | patXData | long | expanded pattern data |
14 | patXValid | word | for expanded pattern data |
16 | patXMap | long | handle to expanded pattern data |
20 | pat1Data | 8 bytes | a bit pattern for a GrafPort record |
| | | |
CQDProcs Data Structure
0 | textProc | long | pointer to text-drawing routine |
4 | lineProc | long | pointer to line-drawing routine |
8 | rectProc | long | pointer to rectangle-drawing routine |
12 | rRectProc | long | pointer to rounded rectangle-drawing routine |
16 | ovalProc | long | pointer to oval-drawing routine |
20 | arcProc | long | pointer to arc/wedge-drawing routine |
24 | polyProc | long | pointer to polygon-drawing routine |
28 | rgnProc | long | pointer to region-drawing routine |
32 | bitsProc | long | pointer to bit transfer routine |
36 | commentProc | long | pointer to picture comment-processing routine |
40 | txMeasProc | long | pointer to text-width measurement routine |
44 | getPicProc | long | pointer to picture retrieval routine |
48 | putPicProc | long | pointer to picture-saving routine |
52 | opcodeProc | long | reserved for future use |
56 | newProc1 | long | reserved for future use |
60 | newProc2 | long | reserved for future use |
64 | newProc3 | long | reserved for future use |
68 | newProc4 | long | reserved for future use |
72 | newProc5 | long | reserved for future use |
76 | newProc6 | long | reserved for future use |
GrafVars Data Structure
0 | rgbOpColor | 6 bytes | color for addPin , subPin , and blend |
6 | rgbHiliteColor | 6 bytes | color for highlighting |
12 | pmFgColor | long | palette handle for foreground color |
16 | pmFgIndex | short | index value for foreground color |
18 | pmBkColor | long | palette handle for background color |
22 | pmBkIndex | short | index value for background color |
24 | pmFlags | short | flags for Palette Manager |
Trap Macros Requiring Routine Selectors
_QDExtensions
Selector | Routine |
$00040007 | CTabChanged |
$00040008 | PixPatChanged |
$00040009 | PortChanged |
$0004000A | GDeviceChanged |
Result Codes
noErr | 0 | No error |
paramErr | -50 | Illegal parameter to NewGWorld |
| -143 | CopyBits couldn't allocate required temporary memory |
| -144 | Ran out of stack space while drawing polygon |
noMemForPictPlaybackErr | -145 | Insufficient memory for drawing the picture |
regionTooBigError | -147 | Region too big or complex |
pixmapTooDeepErr | -148 | Pixel map is deeper than 1 bit per pixel |
nsStackErr | -149 | Insufficient stack |
cMatchErr | -150 | Color2Index failed to find an index |
cTempMemErr | -151 | Failed to allocate memory for temporary structures |
cNoMemErr | -152 | Failed to allocate memory for structure |
cRangeErr | -153 | Range error on color table request |
cProtectErr | -154 | ColorTable record entry protection violation |
cDevErr | -155 | Invalid type of graphics device |
cResErr | -156 | Invalid resolution for MakeITable |
cDepthErr | -157 | Invalid pixel depth specified to NewGWorld |
rgnTooBigErr | -500 | Bitmap would convert to a region greater than 64 KB |