Hello everyone,
I can't seem to get this to work, yet it seems like it should be so
easy. I have an NSBitmapImageRep, and I want to crop it to a given
NSRect. The code I've attempted so far is this:
// Create an NSImage for the current image rep
NSImage *source = [[NSImage
On 21 Apr 2008, at 9:43 pm, Daniel Thorpe wrote:
[source compositeToPoint:NSZeroPoint fromRect:extent
operation:NSCompositeSourceIn fraction:1.0];
Try using NSCompositeSourceCopy here instead.
G.
___
Cocoa-dev mailing list
Oops, I meant NSCompositeCopy
g.
On 21 Apr 2008, at 9:55 pm, Graham Cox wrote:
On 21 Apr 2008, at 9:43 pm, Daniel Thorpe wrote:
[source compositeToPoint:NSZeroPoint fromRect:extent
operation:NSCompositeSourceIn fraction:1.0];
Try using NSCompositeSourceCopy here instead.
G.
Hard to tell from the code posted. Maybe extent is incorrect?
You can just draw the source imageRep directly - you don't have to
wrap it in an image, and given that you just want a straight copy
it'll be simpler too. Use [imageRep drawAtPoint:...] This may not have
a bearing on your
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.
I think the problem might be that the cropping is working fine, it's
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
Right, well, I've solved my problem, but using a completely different
method. I still don't know/understand how to crop an NSImage to a
smaller NSRect within the image's bounds.
However, this is what I've done to solve this...
// imageRep is my NSBitmapImageRep which contains the