How to access pixels of an NSBitmapImageRep?
- by Paperflyer
I have an NSBitmapImageRep that is created like this:
NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:waveformSize.width
pixelsHigh:waveformSize.height
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:YES
colorSpaceName:NSCalibratedRGBColorSpace
bytesPerRow:0
bitsPerPixel:0];
Now I want to access the pixel data so I get a pointer to the pixel planes using
unsigned char *bitmapData;
[imageRep getBitmapDataPlanes:&bitmapData];
According to the Documentation this returns a C array of five character pointers. But how can it do that? since the type of the argument is unsigned char **, it can only return an array of chars, but not an array of char pointers.
So, this leaves me wondering how to access the individual pixels. Do you have an idea how to do that?
(I know there is the method – setColor:atX:y:, but it seems to be pretty slow if invoked for every single pixel of a big bitmap.)