Re: How to draw text to bitmap (array) with pre 10.5 libs
Re: How to draw text to bitmap (array) with pre 10.5 libs
- Subject: Re: How to draw text to bitmap (array) with pre 10.5 libs
- From: John Horigan <email@hidden>
- Date: Tue, 1 Dec 2009 00:25:44 -0800
>>
>> Indeed, the initWithBitmapDataPlanes method treats the supplied buffer as immutable and creates its own internal copy.
>
> This is not correct. From the docs [1]:
>
> "If planes is not NULL and the array contains at least one data pointer, the returned object will only reference the image data; it will not copy it. The object treats the image data in the buffers as immutable and will not attempt to alter it. When the object itself is freed, it will not attempt to free the buffers."
>
> Because of this, it's generally easier to let NSBitmapImageRep create the buffer for you, at least if you're going to be keeping it around.
>
>> 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).
>
> My understanding is that this only applies if you create the bitmap rep with initWithCGImage: (which is an odd limitation to keep track of). You can still modify bitmap data from ordinary NSBitmapImageRep instances, but it will be slow since NSBitmapImageRep has to recache. Of course, this is just my interpretation of the release notes [2] so I'd be interested in information to the contrary.
>
The docs may still say that the object references your bitmap without copying it, but my experience is that this is not true in 10.6. NSBitmapImageReps are backed by CGImages in 10.6 even if you create them with initWithBitmapDataPlanes. I don't know if the CGImage is created right away or lazily but I don't think that the statement that the reference bitmap is not copied is true in 10.6. If you draw into a NSBitmapImageRep then it must copy the reference bitmap as the docs promise that the reference bitmap will not be modified.
-- john
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden