discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Extracting from NSImage (NSImageView)


From: Vaisburd, Haim
Subject: RE: Extracting from NSImage (NSImageView)
Date: Thu, 3 Jun 2004 13:16:00 -0700

Hi,

> I would like to create a new image by extracting the rect 
> {100,100, 640, 480} from the imageView I tried to do that with
>
>          NSData *result = [imageView dataWithPDFInsideRect:subFrame];
>
> where subFrame = {100,100, 640, 480}, However, this give me not the 
> portion of the image I requested [...]

I do not whether NSImageView can be used for this purpose,
but, as far as I understand, cropping is the job of NSImage class.

I think you can use Cocoa's method
[NSImage -compositeToPoint:fromRect:operation:fraction:]

http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC
_classic/Classes/NSImage.html#//apple_ref/doc/uid/20000344/BCIIJGIC

If you want to create an image from a portion of original one,
you need to calculate the new size, create this new image and
then draw _on it_ by locking focus:

[newImage lockFocus];
[originalImage compositeToPoint: ....];
[newImage unlockFocus];

I say "I think" because I never used Cocoa, and
[NSImage -compositeToPoint:fromRect:operation:fraction:]
was not implemented in GNUstep the last time I checked.

Does anybody know why it's not implemented?

Thank you,
Tima.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]