Hi Jean-Nicolas, This is not a bad way to resize images, but a few things come to mind that you could try:
(1) Run it shark to make sure that it's really the image drawing that's getting you, and not something else that is avoidable. You could accidentally be creating redundant copies of image buffers, for example. (2) Lower the quality of the resize with -[NSGraphicsContext setImageInterpolation:]. (3) Use NSOperationQueue to resize different images concurrently. You will hopefully get a boost on multicore systems. (4) Try using CoreImage instead. Using CG vs NS should not make any difference. It boils down to the same thing. CoreImage is different though.. there may be a gain there, particularly for large images. > however I found out that just using the setSize: method of NSImage was > unreliable -[NSImage setSize:] doesn't change the pixels of an image, it changes the natural size that the image is drawn at. If you try to write the NSImage back out as a TIFF, say, then what you've done is modify the DPI. -Ken On Wed, Nov 19, 2008 at 10:30 PM, Jean-Nicolas Jolivet <[EMAIL PROTECTED]> 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/kenferry%40gmail.com > > This email sent to [EMAIL PROTECTED] > _______________________________________________ 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]