On 21 Apr 2008, at 11:21 pm, Daniel Thorpe wrote:
The extent rect is correct, I've double checked that.

Looking at the docs for NSImageRep's drawAtPoint and drawInRect methods, it looks like they only allow you to draw the whole image rep, not a rect within the rep.

True, but if you don't need to scale the image, it's fine - just offset the point to the negative of the origin of the desired source rectangle. Only the pixels that the destination needs are copied.

I think the problem might be that the cropping is working fine, it's just that I'm not viewing the result correctly, if I print out the description of the result's representations array, I get this:

NSCachedImageRep 0x1f6b30 Size={101, 120} ColorSpace=NSCalibratedRGBColorSpace BPS=8 Pixels=101x120 Alpha=YES

So, perhaps the TIFFRepresention method of the NSImage doesn't actually return the pixels? Perhaps?

-TIFFRepresentation just creates the data on the fly (after all, it returns NSData, not an NSImageRep).

I'm wondering if the black image is to do with the alpha of your source image? - often problems with alpha produce a black result. But I'm afraid I can't really suggest anything to try here. I think what you're doing is basically correct though - I've frequently done much the same and had good results.

G.


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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