Re: Scaling down an image proportionally
Re: Scaling down an image proportionally
- Subject: Re: Scaling down an image proportionally
- From: Thilo Ettelt <email@hidden>
- Date: Sat, 21 Sep 2002 20:19:24 +0200
Thx, I simply used an NSImageCell as I needed the image inside an
NSMatrix.
Cheers, Thilo
Am Samstag, 21.09.02 um 19:44 Uhr schrieb Marco Binder:
If you need a way to render down the actual image data, so you can e.g.
save it to disk in a smaller version, you can just create a new NSImage
with
NSImage *newImage = [[NSImage alloc] initWithSize:(NSSize)];
in the new desired size (that is, for proportional scaling [yourImage
size].width*x and [yourImage size]. height*x), then lockFocus on this
new image and call
[yourImage drawInRect:NSMakeRect(0,0,[newImage size].width,[newImage
size].height) fromRect:NSMakeRect(0,0,[yourImage size].width,[yourImage
size].height) operation:NSCompositeCopy fraction:1.0];
newImage now holds your proportionally scaled down original image.
In case you just need a way to display a scaled version on screen, the
easiest and cleanest way is to just follow the docs:
Taken from Apple4s developer documentation:
scalesWhenResized
- (BOOL)scalesWhenResized
Returns YES if image representations are scaled to fit the size
specified for the receiver. If representations are not scalable, this
method returns NO. The default is NO.
Representations created from data that specifies a size (for example,
the "ImageLength" and "ImageWidth" fields of a TIFF representation or
the bounding box of an EPS representation) will have the size the data
specifies, which may differ from the size of the NSImage.
See Also: - setSize:
marco
Am Samstag, 21.09.02 um 18:44 Uhr schrieb Thilo Ettelt:
Hi! Could someone give me a hint how I can scale an NSImage down
proportionally?
Thx in advance!
Cheers, Thilo
--
|\ /| E-Mail: email@hidden WWW: www.marco-binder.de
| \/ | Telefon: 07531 / 94 19 94 Fax: 07531 / 94 19 92
| |ARCO Snail-Mail: Banater Str. 3 - 78467 Konstanz
BINDER _____________________________________________________
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.