Important: The information in this document is obsolete and should not be used for new development.
GetPictInfo
Use theGetPictInfo
function to gather information about a single picture.
FUNCTION GetPictInfo (thePictHandle: PicHandle; VAR thePictInfo: PictInfo; verb: Integer; colorsRequested: Integer; colorPickMethod: Integer; version: Integer): OSErr;
thePictHandle
- A handle to a picture.
thePictInfo
- A pointer to a
PictInfo
record, which will hold information about the picture. ThePictInfo
record is described on page 7-31.verb
- A value indicating what type of information you want
GetPictInfo
to return in thePictInfo
record. You can use any or all of the following constants or the sum of the integers they represent:CONST returnColorTable = 1; {return a ColorTable record} returnPalette = 2; {return a Palette record} recordComments = 4; {return comment information} recordFontInfo = 8; {return font information} suppressBlackAndWhite = 16; {don't include black and } { white with returned colors}
- Because the Palette Manager adds black and white when creating a
Palette
record, you can specify the number of colors you want minus 2 in thecolorsRequested
parameter and specify thesuppressBlackAndWhite
constant in theverb
parameter when gathering colors destined for aPalette
record or a screen.colorsRequested
- From 1 to 256, the number of colors you want in the
ColorTable
orPalette
record returned via thePictInfo
record. If you are not requesting colors (that is, if you pass therecordComments
orrecordFontInfo
constant in theverb
parameter), this function does not return colors, in which case you may instead pass 0 here.colorPickMethod
- The method by which colors are selected for the
ColorTable
orPalette
record returned via thePictInfo
record. You can use one of the following constants or the integer it represents:CONST systemMethod = 0; {let Picture Utilities choose } { the method (currently they } { always choose popularMethod)} popularMethod = 1; {return most frequently used } { colors} medianMethod = 2; {return a weighted distribution } { of colors}
- You can also create your own color-picking method in a resource file of type
'cpmt'
and pass its resource ID in thecolorPickMethod
parameter. The resource ID must be greater than 127.version
- Always set this parameter to 0.
DESCRIPTION
In thePictInfo
record to which the parameterthePictInfo
points, theGetPictInfo
function returns information about the picture you specify in thethePictHandle
parameter. Initially, all of the fields in a newPictInfo
record are set toNIL
. Relevant fields are set to appropriate values depending on the information you request using theGetPictInfo
function.Use the
verb
parameter to specify whether you want color information (in aColorTable
record, aPalette
record, or both), whether you want picture comment information, and whether you want font information. If you want color information, be sure to use thecolorPickMethod
parameter to specify the method by which to select colors.The Picture Utilities provide two color-picking methods: one (specified by the
popularMethod
constant) that gives you the most frequently used colors and one (specified by themedianMethod
constant) that gives you the widest range of colors. Each has advantages in different situations. For example, suppose the picture of a forest image contains 400 colors, of which 300 are greens, 80 are browns, and the rest are a scattering of golden sunlight effects. If you ask for the 250 most used colors, you will probably receive all greens. If you ask for a range of 250 colors, you will receive an assortment stretching from the greens and golds to the browns, including colors in between that might not actually appear in the image. If you specify thesystemMethod
constant, the Picture Utilities choose the method; currently they always choosepopularMethod
. You can also supply a color-picking method of your own.If your application uses more than one color-picking method, it should present the user with a choice of which method to use.
When you are finished with the information in the
PictInfo
record, be sure to dispose of it. Use the Memory Manager procedureDisposeHandle
to dispose of thePictInfo
,CommentSpec
, andFontSpec
records. Dispose of thePalette
record by using theDisposePalette
procedure. Dispose of theColorTable
record by using theDisposeCTable
procedure.SPECIAL CONSIDERATIONS
When you ask for color information,GetPictInfo
takes into account only the version 2 and extended version 2 picture opcodesRGBFgCol
,RGBBkCol
,BkPixPat
,PnPixPat
,FillPixPat
, andHiliteColor
(as well as pixel map or bitmap data). Each occurrence of these opcodes is treated as 1 pixel, regardless of the number and sizes of the objects drawn with that color. If you need an accurate set of colors from a complex picture, create an image of the picture in an offscreen pixel map, and then call theGetPixMapInfo
function (described on page 7-49) to obtain color information about that pixel map.The
GetPictInfo
function returns a bit depth of 1 on QuickTime-compressed'PICT'
files. However, when QuickTime is installed, QuickTime decompresses and displays the image correctly.The
GetPictInfo
function may move or purge memory.ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for theGetPictInfo
function are
Trap macro Selector _Pack15 $0800 RESULT CODES
SEE ALSO
ThePictInfo
record is described on page 7-31, theCommentSpec
record is described on page 7-29, and theFontSpec
record is described on page 7-29. TheColorTable
record is described in the chapter "Color QuickDraw" in this book; thePalette
record is described in the chapter "Palette Manager" in Advanced Color Imaging on the Mac OS. See "Application-Defined Routines" beginning on page 7-60 for more information about creating your own color-picking method for thecolorPickMethod
parameter.The
DisposePalette
procedure is described in the chapter "Palette Manager" in Advanced Color Imaging on the Mac OS. TheDisposeCTable
procedure is described in the chapter "Color QuickDraw" in this book. TheDisposeHandle
procedure is described in the chapter "Memory Manager" in Inside Macintosh: Memory.Listing 7-12 on page 7-24 illustrates the use of the
GetPictInfo
function.