Re: - [NSBitmapImageRep tiffRepresentation] malloc error
Re: - [NSBitmapImageRep tiffRepresentation] malloc error
- Subject: Re: - [NSBitmapImageRep tiffRepresentation] malloc error
- From: David Duncan <email@hidden>
- Date: Mon, 15 Dec 2008 13:50:32 -0800
On Dec 15, 2008, at 12:47 PM, Thomas Clement wrote:
The work around is to draw the part of the image you want to work
with. You can do this with either AppKit or Core Graphics using
NSBitmapImageRep or a bitmap context (created via
CGBitmapContextCreate).
Alright but how am I suppose to draw a part of the image without
loading the whole image from disk first?
Creating a NSBitmapImageRep requires creating a NSData with the
whole image.
I tried using CGBitmapContextCreate but I got a malloc error again
when calling CGContextDrawImage (passing a small rect to draw).
If you use the bitmap context method, then you create a context that
is the size of the image data that you want (so if you want a 20x20
section of the image, you create a 20x20 context) then draw the whole
image to it. If you use ImageIO to load the image, then it will only
load portion of the image required to draw that area. In order to get
the correct part of the image, you would need to translate the context
(via CGContextTranslateCTM for example) to position the image correctly.
I think this is described (perhaps not in total) in the Quartz 2D
Programming Guide <http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_intro/chapter_1_section_1.html
> so you should have a look there.
--
David Duncan
Apple DTS Animation and Printing
_______________________________________________
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