Image loading bug out of nowhere...
Image loading bug out of nowhere...
- Subject: Image loading bug out of nowhere...
- From: Michael Becker <email@hidden>
- Date: Thu, 3 Nov 2005 13:15:15 +0100
Hi,
I have a very heavy bug in my application and don't even know where
to start looking for it. It has to do with loading JPEG images. I
read out the iPhoto library and load the thumbnail images. For
testing purposes, I created about 300 copies of one 1,2 MB JPEG image
and imported them into iPhoto.
Now when my program loads all those images, there's always a certain
point where no images will be loaded anymore and nothing else works
(e.g. clicking an "Open" Button in my application results in an error
message "unable to load nib data: /System/Library/Frameworks/
AppKit.framework/Resources/English.lproj/NSNavPanelContentView.nib").
"newImage" in the code below will be an object of my own image
storage class.
Here's basically how I load the images (I want to know the original
image's size, however):
NSData *imageData = [[NSData alloc]
initWithContentsOfFile:thumbnailPath];
NSBitmapImageRep *bitmapImageRep = nil;
char buffer[3];
[imageData getBytes:&buffer length:3];
if (([[[path pathExtension] lowercaseString]
hasPrefix:@"jp"]) &&
(buffer[0] == -1) &&
(buffer[1] == -40) &&
(buffer[2] == -1))
{
bitmapImageRep = [[NSBitmapImageRep
imageRepWithContentsOfFile:thumbnailPath] retain];
// Load the original fullsize image to find out its
dimensions
NSData *fullsizeData = [[NSData alloc]
initWithContentsOfFile:path];
NSBitmapImageRep *sizeRep = [[NSBitmapImageRep
alloc] initWithData:fullsizeData];
// Set original image size in our new object
[newImage setImageSize:NSMakeSize([sizeRep
pixelsWide], [sizeRep pixelsHigh])];
[sizeRep release];
[fullsizeData release];
}
This works fine until I put in too many images of too big filesizes.
Suddenly (in my above example at image no. 217) no images will be
loaded and the buffer-array will hold values like (-94, -121, 106) or
(-112, 114, -12). Sometimes even the application's main menu gets
screwed up, displaying nothing but strange characters (its basically
an "A" inside a square box).
This looks to me like some big memory desaster, but I have no idea
where to start looking...
Regards,
Michael
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden