Mailing Lists: Apple Mailing Lists

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

Re: kCGImageAlphaFirst not implemented (Was: (no subject))




Ken -

Thanks for your time and input on the issue... I've filed a radar on this issue -- hopefully, this issue will get some visibilty since the only workaround is to either ditch QuickTime/ImageIO or to use a deprecated API (GWorlds).


Well, it may be that what you want to do is beyond the scope of what Apple sortof intends ImageIO to be used for. I'm not sure if using ImageIO + CoreGraphics was ever really targetted at being used for an image loading scheme for OpenGL applications.

I assumed that the only way to read an image from somewhere, have access to the source RGBA data for application-level editing, and upload it as a texture was via GraphicsImportCreateCGImage() and CGBitmapContextCreate(). Is there any way to this that isn't deprecated?


In any case, thanks again.

Regards,
Andy




On May 15, 2007, at 2:16 AM, Kenneth Dyke wrote:

On May 14, 2007, at 6:34 PM, Andy O'Meara wrote:


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.

Honestly, I wouldn't expect CGBitmapContextCreate() to support non- premultiplied alpha any time soon. There are various sound mathematical reasons why CG does everything in premultiplied space and wants to leave it that way. That being said, I hear you. It's probably worth filing a Radar against ImageIO at the very least that says you need to be able to get at the original unpremultiplied alpha values when they are present in an image. If you can explain in as much detail as possible what it is you need to achieve and why premultiplied alpha will not work in your case, that would probably help things greatly.


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?

Well, it may be that what you want to do is beyond the scope of what Apple sortof intends ImageIO to be used for. I'm not sure if using ImageIO + CoreGraphics was ever really targetted at being used for an image loading scheme for OpenGL applications. Certainly ImageIO also uses libpng internally AFAIK, and is also passing non-premultiplied alpha into CoreGraphics.


I think fundamentally CoreGraphics is designed to accept premultiplied alpha on *input*, it just never outputs it for various reasons. I believe it has something to do with the compositing mathematics. Someone from the CG team could probably explain the rationale much better than I could. I found this page which probably is as good as anything, and my guess is that CG is the way it is because it boils down to the issues surrounding the compositing mathematics and the speed you get from storing things in premultiplied format: http://en.wikipedia.org/wiki/ User:Lkesteloot/premultiplied_alpha

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

That's a judgement call you'll have to make on your own. I can't promise anything one way or another. Again, when it doubt, *always* file a Radar.


-Ken




_______________________________________________ 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>)
 >kCGImageAlphaFirst not implemented (Was: (no subject)) (From: Andy O'Meara <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.