Important: The information in this document is obsolete and should not be used for new development.
LockPixels
To prevent the base address for an offscreen pixel image from being moved while you draw into or copy from its pixel map, use theLockPixels
function.
FUNCTION LockPixels (pm: PixMapHandle): Boolean;
pm
- A handle to an offscreen pixel map. To get a handle to an offscreen pixel map, use the
GetGWorldPixMap
function, described on page 6-31.DESCRIPTION
TheLockPixels
function prevents the base address for an offscreen pixel image from being moved. You must callLockPixels
before drawing to or copying from an offscreen graphics world.The
baseAddr
field of thePixMap
record for an offscreen graphics world contains a handle instead of a pointer (which is what thebaseAddr
field for an onscreen pixel map contains). TheLockPixels
function dereferences thePixMap
handle into a pointer. When you use theUnlockPixels
procedure, which is described next, the handle is recovered.If the base address for an offscreen pixel image hasn't been purged by the Memory Manager or is not purgeable,
LockPixels
returnsTRUE
as its function result, and your application can draw into or copy from the offscreen pixel map. However, if the base address for an offscreen pixel image has been purged,LockPixels
returnsFALSE
to indicate that you can perform no drawing to or copying from the pixel map. At that point, your application should either call theUpdateGWorld
function (described on page 6-23) to reallocate the offscreen pixel image and then reconstruct it, or draw directly in a window instead of preparing the image in an offscreen graphics world.As soon as you are finished drawing into and copying from the offscreen pixel image, you should call the
UnlockPixels
procedure.SPECIAL CONSIDERATIONS
TheLockPixels
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 theLockPixels
function are
Trap macro Selector _QDExtensions $00040001 SEE ALSO
Listing 6-1 on page 6-5 and Listing 6-2 on page 6-10 illustrate the use of this function. See Inside Macintosh: Memory for more information about memory management.