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.



_______________________________________________
Gnustep-dev mailing list
Gnustep-dev@gnu.org
http://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to