Answered my own question ... apologize for the noise!
On Jan 7, 2010, at 4:05 PM, David Blanton wrote:

Thanks to all.

I have my bitmap being drawn but it is upside down.

Do isFlipped play any role in this / how do I get it to draw right side up without inverting my raw data?

For those interested this is the correct definition of NSBitMapImageRep:

        m_ptrs[0] = (unsigned char*)m_bitmap.m_array;
        m_NSBitmapImageRep = [[NSBitmapImageRep alloc]
                                                  
initWithBitmapDataPlanes:m_ptrs
                                                  pixelsWide:m_bitmap.m_pixelsx
                                                  pixelsHigh:m_bitmap.m_pixelsy
                                                  bitsPerSample:8
                                                  samplesPerPixel:3
                                                  hasAlpha:NO
                                                  isPlanar:NO
                                                  
colorSpaceName:NSCalibratedRGBColorSpace
                                                  
bitmapFormat:NSAlphaNonpremultipliedBitmapFormat
                                                  
bytesPerRow:(4*m_bitmap.m_pixelsx)
                                                  bitsPerPixel:32];




On Jan 6, 2010, at 11:32 AM, David Duncan wrote:

On Jan 6, 2010, at 10:19 AM, David Blanton wrote:

Now, from David Duncan's comment.

My bitmap data does have alpha, i.e 4 samples per pixel ARGB. I thought kCGImageAlphaNoneSkipFirst says don't make an alpha plane, skip byte 1 and go to RED.

I am not sure how to specify this in the 'bitmapFormat' parameter.

AlphaNoneSkipFirst means you have no alpha, and skip any leading bytes per necessary to fill the pixel size. In your particular case since you have 8 bits per component and 3 components, that means skip the first 8 bits of each word then decode 8 bits for each of 3 components.

When you create your NSBitmapImageRep however, you specify that there is alpha, which means that you are specifying the equivalent of kCGImageAlphaPremultipliedFirst (since you don't specify the NSAlphaNonpremultipliedBitmapFormat flag). What you really want is to specify no alpha and 3 samples per pixel (if I'm not mistaken, I usually work in Quartz rather than NS for graphics). Specifying 32 bits per pixel as you do should get the same interpretation that you are currently getting via Quartz.

Also keep in mind that your Quartz code is more work than you would actually need. Since you aren't drawing to your image data, you should create the CGImage directly via CGImageCreate rather than using CGBitmapContextCreate to then extract a CGImage – the performance difference is in the syscalls necessary to mark the memory for the bitmap context as copy-on-write.
--
David Duncan
Apple DTS Animation and Printing




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/airedale%40tularosa.net

This email sent to aired...@tularosa.net



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to