NSImage & memory
NSImage & memory
- Subject: NSImage & memory
- From: Jeremy Rotsztain <email@hidden>
- Date: Tue, 17 Jul 2007 13:20:10 -0400
Hey.
I'm running into problems managing images and memory.
I'm creating a NSImage and writing its contents to disk (by
generating a TIFF representation of the NSImage).
When I try to release the NSData related to that image, my
application crashes.
I'm doing some reading on memory allocation, but I can't find a
straight-forward answer to my problem.
Should I be using autorelease pools?
Thanks for any input,
Jeremy
// image size
NSSize imgNewSize = NSMakeSize(320, 240);
// generate the image
tmpImg = [[ NSImage alloc] initWithSize:imgNewSize ]];
// fill image with solid color
[ tmpImg lockFocus ];
[[ NSColor blackColor ] set];
[ NSBezierPath fillRect: NSMakeRect( 0, 0, imgNewSize.width,
imgNewSize.height )];
[ tmpImg unlockFocus ];
// write image to disk
NSData *tmpImgTIFFData = [ tmpImg TIFFRepresentation ];
[ tmpImgTIFFData writeToFile:@"/Users/kiev/Desktop/
FlickrComposition.tiff" atomically:YES ];
// release data
[ tmpImgTIFFData release ];
[ tmpImg release ];
_______________________________________________
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