On Nov 29, 2009, at 9:09 PM, Graham Cox wrote:

> 
> On 30/11/2009, at 2:44 PM, Glenn McCord wrote:
> 
>> What I'm expecting is the drawAtPoint method to draw nsString inside
>> the bitmapRep of the NSContext at which point I can retrieve the raw
>> data  and do something with it. On account of the data all being zero,
>> I'm obviously doing something wrong and would really appreciate some
>> advice.
> 
> 
> You also have to lock focus on the bitmap, which requires that it first be 
> added to an NSImage (I think if you are targeting 10.6 only there is a new 
> API that means you can avoid this).
> 
> Also, it's not necessary to allocate the bitmap's buffer - if you don't pass 
> one, it will allocate it for you.
> 
> --Graham
> 

Indeed, the initWithBitmapDataPlanes method treats the supplied buffer as 
immutable and creates its own internal copy. You must request the bitmap back 
from the NSBitmapImageRep using the bitmapData method. Prior to 10.6 the data 
backing up the NSBitmapImageRep was a bitmap plane but in 10.6 the cocoa team 
changed the backing data for NSBitmapImageRep to a CGImage. Either way, you 
should treat the data returned by bitmapData as read-only (in case you were 
thinking of modifying it). 

-- john

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to