[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Cropping an NSImage
From: |
moonlight |
Subject: |
Cropping an NSImage |
Date: |
Sun, 1 May 2005 07:05:35 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Hi!
I'd like to crop an image, and get another NSImage containing the selected
rectangle from the source image.
i tried :
- (NSImage *) imageFromRect: (NSRect) rect
{
NSImage * canvas = [[NSImage alloc] initWithSize: rect.size];
[ canvas setSize: rect.size ];
[ canvas lockFocus ];
[self compositeToPoint: NSZeroPoint
fromRect: rect
operation: NSCompositeCopy];
[ canvas unlockFocus ];
return [canvas autorelease];
}
but it didn't work. Can someone tell me how to do it?
regards.
PS : this code comes from PRICE (i'm not sure of the name of the project)
because i had many unsuccessful attempts with NSAffineTransforms before and
grabbed it from there.
- Cropping an NSImage,
moonlight <=