Re: Completely resizing NSImage
Re: Completely resizing NSImage
- Subject: Re: Completely resizing NSImage
- From: matt neuburg <email@hidden>
- Date: Mon, 29 Mar 2004 12:15:49 -0800
On Fri, 26 Mar 2004 09:41:15 +0100, Michael Becker <email@hidden>
said:
>
My application has to deal with a lot of image thumbnail which it
>
generates. I didn't really think much about it, but recently I've read
>
on this list, that -setSize: doesn't "truly" resize the image, only a
>
representation of it (as far as i remember).
>
I've checked my application's memory usage using the unix "top"
>
command, only to realise in shock that when holding about 40 thumbnails
>
it uses more than 100 MB of memory.
>
>
I've replaced the -setSize: call with creating another NSImage through
>
"initWithSize:" and then drawing the old image into the new one and
>
releasing the old one. Now my application will use only about 10 MB
>
when holding about 80 images. So that's a good thing :-)
>
>
My question: Are there any other "traps" when dealing with NSImage? Are
>
there any switches or the like for turning off any additional
>
complexity?
I too have a thumbnail-generating app, and I found that I didn't even need
NSImage to make the thumbnails. I just read the images from disk into an
NSBitmapImageRep, create the thumbnail into my "master" NSImage using
drawRect:, and release the bitmap. This avoids the overhead of an NSImage's
unwanted representations and caching behavior. m.
--
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide! NOW SHIPPING...! (Finally.)
http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.