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 theUpdateGWorld
function. You should callUpdateGWorld
after 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,
UpdateGWorld
rescans 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 theboundsRect
parameter. If you specify 0 in this parameter,UpdateGWorld
also copies theGDevice
record from this device to create an offscreenGDevice
record. TheUpdateGWorld
function ignores the value you supply for this parameter if you specify aGDevice
record in theaGDevice
parameter.boundsRect
- The boundary rectangle and port rectangle for the offscreen pixel map. This also becomes the boundary rectangle for the
GDevice
record, ifNewGWorld
creates one. If you specify 0 in thepixelDepth
parameter,NewGWorld
interprets the boundaries in global coordinates, with which it determines which screens intersect the rectangle. (NewGWorld
then uses the pixel depth, color table, andGDevice
record 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
ColorTable
record. If you passNIL
in this parameter,UpdateGWorld
uses the default color table for the pixel depth that you specify in thepixelDepth
parameter; if you set thepixelDepth
parameter to 0,UpdateGWorld
copies 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 theboundsRect
parameter. TheUpdateGWorld
function ignores the value you supply for this parameter if you specify aGDevice
record in theaGDevice
parameter.aGDevice
- As an option, a handle to a
GDevice
record 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 thepixelDepth
andcTable
parameters, 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 eitherclipPix
orstretchPix
to 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
TheUpdateGWorld
function changes an offscreen graphics world to the specified pixel depth, rectangle, color table, and options that you supply in thepixelDepth
,boundsRect
,cTable
, andflags
parameters, respectively. In theoffscreenGWorld
parameter, pass the pointer returned to your application by theNewGWorld
function when you created the offscreen graphics world.If the
LockPixels
function (described on page 6-32) reports that the Memory Manager has purged the base address for the offscreen pixel image, you can useUpdateGWorld
to 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
flags
parameter, you can specify thekeepLocal
flag, 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 useUpdateGWorld
without passing it thekeepLocal
flag, you allow the offscreen pixel image to be cached on a graphics accelerator card if one is present.As its function result,
UpdateGWorld
returns thegwFlagErr
flag ifUpdateGWorld
was unsuccessful; in this case, the offscreen graphics world is left unchanged. You can use theQDError
function, described in the chapter "Color QuickDraw," to help you determine whyUpdateGWorld
failed.If
UpdateGWorld
is successful, it returns a combination of the following flags, which are defined by theGWorldFlags
data type:The
UpdateGWorld
function uses the following algorithm when updating the offscreen pixel image:
- If the color table that you specify in the
cTable
parameter is different from the previous color table, or if the color table associated with theGDevice
record that you specify in theaGDevice
parameter 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
pixelDepth
parameter 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
boundsRect
parameter differs from, but has the same size as, the previous boundary rectangle, QuickDraw realigns the pixel image to the screen for optimum performance for theCopyBits
procedure.- If the rectangle you specify in the
boundsRect
parameter is smaller than the previous boundary rectangle and you specify theclipPix
flag, the pixel image is clipped along the bottom and right edges.- If the rectangle you specify in the
boundsRect
parameter is bigger than the previous boundary rectangle and you specify theclipPix
flag, the bottom and right edges of the pixel image are undefined.- If the rectangle you specify in the
boundsRect
parameter is smaller than the previous boundary rectangle and you specify thestretchPix
flag, the pixel image is reduced to the new size.- If the rectangle you specify in the
boundsRect
parameter is bigger than the previous boundary rectangle and you specify thestretchPix
flag, the pixel image is stretched to the new size.- If the Memory Manager purged the base address for the offscreen pixel image,
UpdateGWorld
reallocates the memory, but the pixel image is lost. You must reconstruct it.
SPECIAL CONSIDERATIONS
TheUpdateGWorld
function 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 theUpdateGWorld
function are
Trap macro Selector _QDExtensions $00160003