What's the most straightforward way of painting RGBA data into a view on Mac OS X?
Long story short, every 60th of a second I have a relatively small buffer (256x240) of RGBA data (8 bits per component, 4 bytes per pixel) that is refreshed with new data, and I want to display it (I guess inside an NSView
, but anything is welcome). What's the most straightforward way to do it? Building a CGImageRef
from a CGBitmapContext
to write it to the CGConte开发者_JAVA百科xtRef
obtained from the NSGraphicsContext
seems a bit convoluted.
Building a CGImageRef from a CGBitmapContext to write it to the CGContextRef obtained from the NSGraphicsContext seems a bit convoluted.
It is. Specifically, the “bit” is CGBitmapContext; you don't need that if you already have raster data to create an image from. Just create the image, and then draw it into the CGContext you got from the current NSGraphicsContext.
精彩评论