Finding out size of NSBitmapImageRep data pointer?
Finding out size of NSBitmapImageRep data pointer?
- Subject: Finding out size of NSBitmapImageRep data pointer?
- From: Andrew Duncan <email@hidden>
- Date: Mon, 19 Jul 2004 15:43:40 -0700
In brief: can I get the size of the memory pointed to by an
NSBitmapImageRep data pointer?
In slightly more depth: I create an NSBitmapImageRep, get its data
pointer, and fill in the data directly. This works fine in my test app,
but in the full app I get a memory exception. Roughly, I'm doing this:
NSBitmapImageRep* _bitmap =
[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:_width
pixelsHigh:_height
bitsPerSample:8
samplesPerPixel:3
hasAlpha:NO
isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bytesPerRow:_width * _bitsPerPixel / 8
bitsPerPixel:_bitsPerPixel];
// For the record, _width = 1680, _height = 1050, _bitsPerPixel = 32.
unsigned long* pBits = [_bitmap bitmapData];
... calculate pixel data ...
*((unsigned long*)(pBits + offset)) = newPixel; // Crashes
EXC_BAD_ACCESS
The crash happens with offset just a bit past 1/4 of the way into the
image. Of course, I am checking all my bit/byte/word etc. counts to
find my off-by-4 error, but it would sure help if I could find out what
Cocoa thinks is the size of the bitmap.
_______________________________________________
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.