Re: resize image with cocoa
Re: resize image with cocoa
- Subject: Re: resize image with cocoa
- From: Dan Messing <email@hidden>
- Date: Tue, 06 Dec 2005 12:52:26 -0600
Oops, I wrote:
[spacerImage drawInRect:NSMakeRect(0,0,100,100) fromRect:NSZeroRect
operation:NSCompositeSourceOver fraction:1.0];
when it should have been:
[sourceImage drawInRect:NSMakeRect(0,0,100,100) fromRect:NSZeroRect
operation:NSCompositeSourceOver fraction:1.0];
(sourceImage, not spacerImage)
You must have another image called spacerImage if that didn't cause
compiler problems? Or, if you did catch that problem... are you sure
your sourceData is valid?
Dan Messing
Stunt Software
http://www.stuntsoftware.com/
On Dec 6, 2005, at 12:06 PM, Francesca Placido wrote:
Il giorno 06/dic/05, alle ore 18:32, Dan Messing ha scritto:
Try something like this (written in Mail):
NSImage *sourceImage = [[NSImage alloc] initWithData:sourceData];
NSImage *resizedImage = [[NSImage alloc] initWithSize:NSMakeSize
(100,100)];
[resizedImage lockFocus];
[[NSGraphicsContext currentContext]
setImageInterpolation:NSImageInterpolationHigh]; // optional -
higher quality resizing
[spacerImage drawInRect:NSMakeRect(0,0,100,100)
fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
[resizedImage unlockFocus];
[img setImage:sourceImage]; // this must have something to do with
some other part of your application?
NSData *resizedData = [resizedImage TIFFRepresentation];
[resizedData writeToFile:pathanteprima2 atomically:YES];
[sourceImage release];
[resizedImage release];
Dan Messing
Stunt Software
http://www.stuntsoftware.com/
Uhm,
thank you ... but I obtain a grey image???
bye
francesca
_______________________________________________
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