• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSBitmapImageRep representationUsingType crashes.....
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSBitmapImageRep representationUsingType crashes.....


  • Subject: NSBitmapImageRep representationUsingType crashes.....
  • From: "Juan P. Pertierra" <email@hidden>
  • Date: Wed, 25 Jan 2006 17:13:53 -0500

There is a detached thread in my cocoa app which simply takes image data from a continuous block of RGB images already in memory, and writes each image to disk in a separate file. I am using initWithBitmapDataPlanes to assign the RGB data to an NSBitmapRep, write the image to disk, and I then release the instance, then use the init method again for the next image. I am using the following line to write the image to disk:

[[imageRep representationUsingType:imageFileType properties:nil] writeToFile:[NSString stringWithFormat:@"./%s_d.%s", takeName, thisFrame, [fileExtension cString]] atomically:NO];

The code runs for a while, but eventually representationUsingType: crashes. If I look at the activity monitor, I also notice that this line seems to consume a very large amount of RAM. if I take this line out, then everything executes normally, without crashing or abnormal memory consumption. Of course, the files are then not written to disk which is what I need.

Below is the relevant code:

ptrFrame = outputBuffer->data; //Pointer to first image
NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: (unsigned char **)&ptrFrame
pixelsWide: 1280
pixelsHigh: 720
bitsPerSample: 8
samplesPerPixel: 3
hasAlpha: NO
isPlanar: NO
colorSpaceName: NSCalibratedRGBColorSpace
bytesPerRow: (1280 * 3)
bitsPerPixel: 24];

for(thisFrame = firstFrame; thisFrame < (firstFrame + frames); thisFrame++)
{
[[imageRep representationUsingType:imageFileType properties:nil] writeToFile:[NSString stringWithFormat:@"./%s_d.%s", takeName, thisFrame, [fileExtension cString]] atomically:NO];
[imageRep release]; //Release object, image already written to disk
ptrFrame = (unsigned char *)ptrFrame + (FRAME_SIZE * 4); //Move pointer to next image
imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes: (unsigned char **)&ptrFrame
pixelsWide: 1280
pixelsHigh: 720
bitsPerSample: 8
samplesPerPixel: 3
hasAlpha: NO
isPlanar: NO
colorSpaceName: NSCalibratedRGBColorSpace
bytesPerRow: (1280 * 3)
bitsPerPixel: 24];
}
[imageRep release];
{END}


Any ideas?

Thanks in advance...
_______________________________________________
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


  • Follow-Ups:
    • [SOLVED]NSBitmapImageRep representationUsingType crashes.....
      • From: "Juan P. Pertierra" <email@hidden>
  • Prev by Date: Retrive NSTabViewItem from its outlet
  • Next by Date: Re: Retrive NSTabViewItem from its outlet
  • Previous by thread: Re: Retrive NSTabViewItem from its outlet
  • Next by thread: [SOLVED]NSBitmapImageRep representationUsingType crashes.....
  • Index(es):
    • Date
    • Thread