Important: The information in this document is obsolete and should not be used for new development.
UpdateGWorld
To change the pixel depth, boundary rectangle, or color table for an existing offscreen graphics world, use theUpdateGWorldfunction. You should callUpdateGWorldafter every update event and whenever your windows move or change size.
FUNCTION UpdateGWorld (VAR offscreenGWorld: GWorldPtr; pixelDepth: Integer; boundsRect: Rect; cTable: CTabHandle; aGDevice: GDHandle; flags: GWorldFlags): GWorldFlags;
offscreenGWorld- On input, a pointer to an existing offscreen graphics world; upon completion, the pointer to the updated offscreen graphics world.
pixelDepth- The pixel depth of the offscreen world; possible depths are 1, 2, 4, 8, 16, and 32 bits per pixel. If you specify 0 in this parameter,
UpdateGWorldrescans the device list and uses the depth of the screen with the greatest pixel depth among all screens whose boundary rectangles intersect the rectangle that you specify in theboundsRectparameter. If you specify 0 in this parameter,UpdateGWorldalso copies theGDevicerecord from this device to create an offscreenGDevicerecord. TheUpdateGWorldfunction ignores the value you supply for this parameter if you specify aGDevicerecord in theaGDeviceparameter.boundsRect- The boundary rectangle and port rectangle for the offscreen pixel map. This also becomes the boundary rectangle for the
GDevicerecord, ifNewGWorldcreates one. If you specify 0 in thepixelDepthparameter,NewGWorldinterprets the boundaries in global coordinates, with which it determines which screens intersect the rectangle. (NewGWorldthen uses the pixel depth, color table, andGDevicerecord from the screen with the greatest pixel depth from among all screens whose boundary rectangles intersect this rectangle.) Typically, your application supplies this parameter with the port rectangle for the onscreen window into which your application will copy the pixel image from this offscreen world.cTable- A handle to a
ColorTablerecord. If you passNILin this parameter,UpdateGWorlduses the default color table for the pixel depth that you specify in thepixelDepthparameter; if you set thepixelDepthparameter to 0,UpdateGWorldcopies and uses the color table of the graphics device with the greatest pixel depth among all graphics devices whose boundary rectangles intersect the rectangle that you specify in theboundsRectparameter. TheUpdateGWorldfunction ignores the value you supply for this parameter if you specify aGDevicerecord in theaGDeviceparameter.aGDevice- As an option, a handle to a
GDevicerecord whose pixel depth and color table you want to use for the offscreen graphics world. To use the pixel depth and color table that you specify in thepixelDepthandcTableparameters, set this parameter toNIL.flags- Options available to your application. You can set a combination of the flags
keepLocal,clipPix,stretchPix, andditherPix. If you don't wish to use any of these flags, pass the empty set ([ ]) in this parameter for Pascal code or pass 0 here for C code. However, you should pass eitherclipPixorstretchPixto ensure that the pixel map is updated to reflect the new color table. The available flags are described here:TYPE GWorldFlags = SET OF ( {flags for UpdateGWorld are listed here} keepLocal, {keep data structures in main memory} clipPix, {update and clip pixel image to new } { boundary rectangle} stretchPix, {update and stretch or shrink pixel } { image to the new boundary rectangle} ditherPix, {include with clipPix or stretchPix } { flag to dither the pixel image} );DESCRIPTION
TheUpdateGWorldfunction changes an offscreen graphics world to the specified pixel depth, rectangle, color table, and options that you supply in thepixelDepth,boundsRect,cTable, andflagsparameters, respectively. In theoffscreenGWorldparameter, pass the pointer returned to your application by theNewGWorldfunction when you created the offscreen graphics world.If the
LockPixelsfunction (described on page 6-32) reports that the Memory Manager has purged the base address for the offscreen pixel image, you can useUpdateGWorldto reallocate its memory. Your application should then reconstruct the pixel image or draw directly in a window instead of preparing the image in an offscreen graphics world.In the
flagsparameter, you can specify thekeepLocalflag, which keeps the offscreen pixel image in Macintosh main memory or returns the image to main memory if it had been previously cached. If you useUpdateGWorldwithout passing it thekeepLocalflag, you allow the offscreen pixel image to be cached on a graphics accelerator card if one is present.As its function result,
UpdateGWorldreturns thegwFlagErrflag ifUpdateGWorldwas unsuccessful; in this case, the offscreen graphics world is left unchanged. You can use theQDErrorfunction, described in the chapter "Color QuickDraw," to help you determine whyUpdateGWorldfailed.If
UpdateGWorldis successful, it returns a combination of the following flags, which are defined by theGWorldFlagsdata type:The
UpdateGWorldfunction uses the following algorithm when updating the offscreen pixel image:
- If the color table that you specify in the
cTableparameter is different from the previous color table, or if the color table associated with theGDevicerecord that you specify in theaGDeviceparameter is different, Color QuickDraw maps the pixel values in the offscreen pixel map to the new color table.- If the value you specify in the
pixelDepthparameter differs from the previous pixel depth, Color QuickDraw translates the pixel values in the offscreen pixel image to those for the new pixel depth.- If the rectangle you specify in the
boundsRectparameter differs from, but has the same size as, the previous boundary rectangle, QuickDraw realigns the pixel image to the screen for optimum performance for theCopyBitsprocedure.- If the rectangle you specify in the
boundsRectparameter is smaller than the previous boundary rectangle and you specify theclipPixflag, the pixel image is clipped along the bottom and right edges.- If the rectangle you specify in the
boundsRectparameter is bigger than the previous boundary rectangle and you specify theclipPixflag, the bottom and right edges of the pixel image are undefined.- If the rectangle you specify in the
boundsRectparameter is smaller than the previous boundary rectangle and you specify thestretchPixflag, the pixel image is reduced to the new size.- If the rectangle you specify in the
boundsRectparameter is bigger than the previous boundary rectangle and you specify thestretchPixflag, the pixel image is stretched to the new size.- If the Memory Manager purged the base address for the offscreen pixel image,
UpdateGWorldreallocates the memory, but the pixel image is lost. You must reconstruct it.
SPECIAL CONSIDERATIONS
TheUpdateGWorldfunction may move or purge memory blocks in the application heap. Your application should not call this function at interrupt time.ASSEMBLY-LANGUAGE INFORMATION
The trap macro and routine selector for theUpdateGWorldfunction are
Trap macro Selector _QDExtensions $00160003