Re: resize image with cocoa
Re: resize image with cocoa
- Subject: Re: resize image with cocoa
- From: Francesca P <email@hidden>
- Date: Tue, 6 Dec 2005 08:44:33 +0100
Have you tried this code example?
I'm using this code-snippet too for generating thumbnail images
and this work for me.
Manfred
--
software by MABE
http://www.software-by-mabe.com
No,
I've tried it now again, but it doesn't constrain proportion of my
image.
It makes an images 100x100 px, but not scale it...
:-(
this is my code, is it wrong???
NSData* sourceData = [immagineDaFile TIFFRepresentation];
float resizeWidth = 130.0;
float resizeHeight = 130.0;
NSImage *sourceImage = [[NSImage alloc] initWithData: sourceData];
NSImage *resizedImage = [[NSImage alloc] initWithSize: NSMakeSize
(resizeWidth, resizeHeight)];
NSSize originalSize = [sourceImage size];
[resizedImage lockFocus];
[sourceImage drawInRect: NSMakeRect(0, 0, resizeWidth, resizeHeight)
fromRect: NSMakeRect(0, 0, originalSize.width, originalSize.height)
operation: NSCompositeSourceOver fraction: 1.0];
[resizedImage unlockFocus];
NSData *resizedData = [resizedImage TIFFRepresentation];
[resizedData writeToFile: pathanteprima2
atomically: YES];
[sourceImage release];
[resizedImage release];
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden