Re: Fastest way to resize an image?
Re: Fastest way to resize an image?
- Subject: Re: Fastest way to resize an image?
- From: Jean-Nicolas Jolivet <email@hidden>
- Date: Sat, 22 Nov 2008 14:12:32 -0500
Well, by digging a bit on cocoabuilder, I found about this cropping
method which is really fast (enough for my needs anyway!)
(imageRep is my BitmapImageRep, fromRect is the rectangle I want to
crop to)
CGImageRef cgImg = CGImageCreateWithImageInRect([imageRep CGImage],
NSRectToCGRect(fromRect));
NSBitmapImageRep *resultRep = [[NSBitmapImageRep alloc]
initWithCGImage:cgImg];
CGImageRelease(cgImg);
Hopefully this can help someone with the same problem in the future!
Thanks to everyone for the help! :)
J-N Jolivet
On 20-Nov-08, at 1:30 AM, Jean-Nicolas Jolivet wrote:
I have a bunch of images to resize... they are located on the HD so
they can be loaded in an NSImage or a BitmapImageRep or pretty much
any way I'd like (CIImage, CGImage are possibilities I guess),
however I found out that just using the setSize: method of NSImage
was unreliable (since basically NSImage is just a "container" for
NSImageReps and such... I was getting unreliable results with
certain images)...
anyway, right now I am loading an NSBitmapImageRep with the
imageRepFromFile: method... then creating a new, empty NSImage
based on the image size that I want to resize to (using
initWithSize:) and I draw the BitmapImageRep on this image (while
the focus is locked on the NSImage)...
This works well and yields reliable results, however the process is
quite slow with bigger images... if I have say 20-30 images to
resize it can take almost a minute... I was wondering if there was a
faster way to achieve the same result (while still getting reliable
results... ). One thing that I have to consider is that I am adding
a border to the images so I might have no other choice but to
actually "draw" them somewhere in the process... but is there
something faster than NSImage/NSImageRep to work with?
Any help/pointers would be appreciated... basically I can already do
what I want to do, just looking for the fastest way to do it...
Jean-Nicolas Jolivet
email@hidden
http://www.silverscripting.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
Jean-Nicolas Jolivet
email@hidden
http://www.silverscripting.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden