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/archive%40mail-archive.com

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

Reply via email to