• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: resize image with cocoa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: resize image with cocoa


  • Subject: Re: resize image with cocoa
  • From: Dan Messing <email@hidden>
  • Date: Tue, 06 Dec 2005 11:32:54 -0600

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/


On Dec 6, 2005, at 10:17 AM, email@hidden wrote:

It's incredible,
I'm trying differents codes, but I can't obtain a scaled images :-(

What is wrong in this code?
I've set setScalesWhenResized :-(


NSImage *sourceImage = [[NSImage alloc] initWithData: sourceData];
[sourceImage lockFocus];
[sourceImage setScalesWhenResized:YES];
[sourceImage setSize: NSMakeSize (100., 100.)];
[img setImage:sourceImage];
NSData *resizedData = [sourceImage TIFFRepresentation];
[sourceImage unlockFocus];
[resizedData writeToFile: pathanteprima2
atomically: YES];

[sourceImage release];


Please help me...

Thank you....

_______________________________________________
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
  • Follow-Ups:
    • Re: resize image with cocoa
      • From: Francesca Placido <email@hidden>
  • Prev by Date: Re: How to find a window under the cursor
  • Next by Date: Re: resize image with cocoa
  • Previous by thread: Re: resize image with cocoa
  • Next by thread: Re: resize image with cocoa
  • Index(es):
    • Date
    • Thread