Re: resize image with cocoa
Re: resize image with cocoa
- Subject: Re: resize image with cocoa
- From: Francesca P <email@hidden>
- Date: Mon, 5 Dec 2005 16:58:45 +0100
Il giorno 05/dic/05, alle ore 15:34, Brian Ganninger ha scritto:
A more thorough answer then scaling and setting sizes like this is
investigate the power of NSAffineTransform, which will allow you to
rotate, scale, and otherwise transform the image (not every single
transform ever, but a fair chunk of the basics.) This will give
you finer grain control over how it behaves (if you so desire).
As to saving, you simply need to use NSFileManager.
// typed in Mail
NSImage *imageToSave = [NSImage imageNamed:@"FooBar"]; // gives us
an image from app's bundle
// you should provide your own path, making sure all components
exist except the file itself
if([[NSFileManager defaultManager] createFileAtPath:@"/
FolderToSaveInto/OurNewImage.tiff"
contents:[imageToSave TIFFRepresentation]
attributes:nil])
{
NSLog(@"we have file save");
}
// you can define your own attribute dictionary or send nil to use
the default
// TIFFRepresentation was used as it provides NSData for easy file
writing, and would likely have the best fidelity
// untested - but I believe it should work... note that you should
save as a supported format of NSImage,
// or just straight use the same format as it came in as
Hope that helps.
uhm,
I'm trying,
but can I save as JPEG image??
Thanks
_______________________________________________
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