Bitmaps and Cocoa
Bitmaps and Cocoa
- Subject: Bitmaps and Cocoa
- From: Darren Ford <email@hidden>
- Date: Sun, 20 Jul 2003 07:28:32 +1000
Hi all,
I've implemented a cross-platform raytracer (in C++) and have hooked
it into a Cocoa frontend. The raytracer works on a pixel-by-pixel
basis and I have a question regarding pixel information and NSImage.
Currently I'm using the 'bitmapData' on a NSBitmapImageRep in order
to place pixel data into an NSImage ie.
myRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL
pixelsWide:x pixelsHigh:y bitsPerSample:8 samplesPerPixel:4
hasAlpha:YES isPlanar:NO colorSpaceName:(NSString
*)NSDeviceRGBColorSpace bytesPerRow:0 bitsPerPixel:0];
pData = [myRep bitmapData];
myImage = [[NSImage alloc] initWithSize:ImageSize];
[myImage addRepresentation:mySmoothedImage];
pData = [myImage bitmapData];
and then using weird offsets in order to place the raw pixel data ie.
pData[yy*4*x + xx*4 + 2] = 50;
pData[yy*4*x + xx*4 + 3] = 70;
etc..
All of this appears to work fine, however I was wondering whether
there was a more elegant way of approaching raw bitmaps? I'm concerned
with the current implementation in that it is not thread safe (my
accessing the data is, however with Cocoa's automatic redrawing there's
the potential that cocoa tries to read at the same time I'm trying to
write my raw data).
Thanks in advance -- Darren.
_______________________________________________
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.