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 PROTECTED]
http://www.silverscripting.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/silvertab%40videotron.ca

This email sent to [EMAIL PROTECTED]

Jean-Nicolas Jolivet
[EMAIL PROTECTED]
http://www.silverscripting.com

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to