On Nov 18, 2008, at 1:02 PM, Darrin Cardani wrote: On Nov 18, 2008, at 9:27 AM, Stonewall Ballard wrote: On Nov 18, 2008, at 12:19 PM, Darrin Cardani wrote: enum CGImageAlphaInfo { kCGImageAlphaNone, /* For example, RGB. */ kCGImageAlphaPremultipliedLast, /* For example, premultiplied RGBA */ kCGImageAlphaPremultipliedFirst, /* For example, premultiplied ARGB */ kCGImageAlphaLast, /* For example, non-premultiplied RGBA */ kCGImageAlphaFirst, /* For example, non-premultiplied ARGB */ kCGImageAlphaNoneSkipLast, /* For example, RBGX. */ kCGImageAlphaNoneSkipFirst, /* For example, XRGB. */ kCGImageAlphaOnly /* No color data, alpha data only */ }; typedef enum CGImageAlphaInfo CGImageAlphaInfo;
So you'd probably want kCGImageAlphaPremultipliedFirst, I believe. Or did you try that and it didn't work?
That is correct. CGBitmapContextCreate complains that it doesn't support 32-bit float pixels with kCGImageAlphaPremultipliedFirst. You can see that here:
Bummer. So you're getting a bitmap and then asking Quartz to draw into it, right? One option would be to tell the host you want a texture, and then download the texture yourself. You can either tell OpenGL to give it to you in the correct order, or you can write a short fragment program to swizzle the color channels before downloading it.
That's an interesting idea, but won't I lose resolution in the floats that way?
It might be just as fast to swizzle the channels manually, if I have to draw into a float bitmap with Quartz. Your explanation is reasonable, but of course, we have to support float RGBA on FCP anyway, so it ends up not being helpful.
I guess templated functions are the way to go, then.
Indeed. Porting from AE to FxPlug required rewriting my image processing library to use three-parameter pixel templates: channel size, channel order, and premultiplication. It ended up being relatively easy to use, but it was painful to get there.
Thanks for the clarification, Darrin.
- Stoney
|