SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 261 | Next

Robert P. Kuehne and J. D. Sullivan

"OpenGL Programming on Mac OS X: Architecture, Performance, and Integration"


Now that we??™ve got a new image into which we can draw new contents,
we make this new image become an active target for rendering by using the
Cocoa Image: NSImage 177
Figure 10-1 NSImage Rendered Before setFlipped (left), and After
setFlipped (right).
lockFocus method. lockFocus (and its counterpart unlockFocus) are elements
of how Quartz rendering works, and not really something we??™ll explore
in detail. The Apple documentation has lots of details on Quartz rendering, so
check there if you are interested in other things you can do with Quartz.
We then tell the current image to draw itself at the new size into the current
Quartz target that is our existing newImage. Finally, we deactivate newImage
as a render target and return that image.
Now that we??™ve computed a ?¬‚ipped image, we need to get the pixel data from
NSImage and download it to the hardware.
Extracting Pixel Data from an NSImage
OpenGL requires access to a raw array of pixels to download those data as either
texture or images to the hardware. For that reason, we must extract our
data from an NSImage and then use the resultant transformed version to pass
data down to the hardware. In Cocoa, a form of image data that allows direct
access to pixel data is NSBitmapImageRep and its subclasses. Speci?¬?cally, an
NSBitmapImageRep has a variety of methods for determining the size and
extent of its contents, as seen in Table 10-1.


Pages:
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273