Re: Resizing an image
Re: Resizing an image
- Subject: Re: Resizing an image
- From: Robert Dell <email@hidden>
- Date: Sun, 22 Jan 2006 07:09:50 -0500
Heinrich Giesen wrote:
On 22.01.2006, at 09:54, Eamon Ford wrote:
I found out how to do it: you have to create a new NSImage of the
desired size, lock focus on it, and draw the original image into the
new one.
That's an overkill.
There really should be an easier way to do it.
Please remember that the natural incarnation (object) of
the data of an image file is an object of one of the subclasses
of NSImageRep and not an NSImage. Locking, drawing, unlocking
wastes a lot of time and space; this will work:
NSBitmapImageRep *theRep = ...;
why dont people like to finish out a line? it's almost as if they are speaking off-the-cuff and have no idea if it will work.
at least that's the impression i get when somebody does that.
// get the rep from the file or:
// in most cases [theOriginalImage objectAtIndex:0] will do it
// but it must be an NSBitmapImageRep
[theRep setSize:theNewSize];
[[theRep representationUsingType:NSJPEGFileType properties:nil] // or
another type
writeToFile:fileName atomically:YES];
The best way to change the size (i.e. the resolution) of an image is
the way sips goes. But sips has some bugs and is not uptodate (Tiger).
_______________________________________________
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