Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

kCGImageAlphaFirst not implemented (Was: (no subject))




Ken,

Thanks for the suggestion, but unfortunately, glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA) isn't a substitute for two reasons...

First, we use CGBitmapContextCreate() in the first place is so that we can perform some arbitrary drawing or processing on the image that we just read in. In our case we perform some custom drawing operations (which require the original RGB values).

Second, we can't use glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA) because we need to use a different blend mode.

As indicated by the other posters here, the frustration seems to be running pretty high on this issue. I mean, with something as powerful as QuickTime, it just seems asinine that you can't get at the original RGBA data.

So is Apple's policy then that we have to use a 3rd party solution (and not QuickTime!) to import an image if we want the actual RGB values? It just seems like it'd be trivial to implement kCGImageAlphaFirst since CGContextDrawImage() multiplies the RGB values by the alpha values--kCGImageAlphaFirst just wouldn't do that multiplication.

If you have any other suggestions, we're all ears. It's just hard to believe that on Mac OS X, we need to use libpng over QuickTime to get the job done -- is this really what Apple wants its developers to do?

I'd be more than willing to spend a tech support incident on this if it will get someone to look into this.

Thanks,
Andy



On May 14, 2007, at 6:08 PM, Kenneth Dyke wrote:


On May 14, 2007, at 2:47 PM, James Walker wrote:

Andy O'Meara wrote:
As OGLers here know, one regularly needs to upload textures that have an alpha channel (with non-multiplied RGB).
Pardon my ignorance, but why? If you just want to apply an RGBA texture, you can use premultiplied alpha.

Indeed. The WindowServer uses pre-multiplied ARGB data from window backing stores all the time:


glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA) is your friend. ;)

-Ken






On May 14, 2007, at 6:24 PM, James Milne wrote:
Andy O'Meara wrote:

As OGLers here know, one regularly needs to upload textures that have an alpha channel (with non-multiplied RGB). Meanwhile, CGBitmapContextCreate() doesn't support kCGImageAlphaFirst (see Apple QA 1037), which makes CGBitmapContextCreate() utterly useless for getting true image RGBA data from a CGImage (see QA1509). Am I going nuts or is this kind of ridiculous for anyone loading images in to be used as textures (with alpha) in OpenGL?


Given this, what's the best-performance way to upload images from arbitrary image files? High performance and low overhead is critical since we can't keep all the textures that we use memory resident.

I don't appear to be the only one running into this...

http://lists.apple.com/archives/carbon-dev/2006/Jan/msg01055.html
http://lists.apple.com/archives/mac-opengl/2006/Apr/msg00045.html
http://lists.apple.com/archives/carbon-dev/2006/Feb/msg00030.html

I got into this mess because I wanted to move away from all the deprecated (GWorld) stuff. Now it looks GraphicsImportSetGWorld() is the only way to get the non-premultiplied image data. So much for leaving QuickDraw...

Any recommendations would be kindly appreciated.
You could simply upload the textures with pre-multiplied alpha then blend them using glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );

Alternatively, if you're doing something that doesn't lend itself to using the textures in their pre-multiplied form, you can upload the texture to OpenGL as-is, lying about the true ordering of the components (saying its ARGB when it's really RGBA), and unswizzle the components in a fragment program.

   real_texture.rgba = texture.argb;

At least, I think this should be the correct swizzling...

--
James Milne



_______________________________________________ Do not post admin requests to the list. They will be ignored. Mac-opengl mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/mac-opengl/email@hidden

This email sent to email@hidden
References: 
 >(no subject) (From: Andy O'Meara <email@hidden>)
 >Re: (no subject) (From: James Walker <email@hidden>)
 >Re: (no subject) (From: Kenneth Dyke <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.