Hi, I'm currently a little puzzled about how alpha premultiplication and BufferedImages work.. I'm implementing a reader for the Photoshop (PSD) format. From what I understand, this format uses color data with premultiplied alpha (is there a way to determine if data is premultiplied, looking at the data?). The way I read data, is first creating a BufferedImage of type TYPE_4BYTE_ABGR or TYPE_4BYTE_ABGR_PRE, then pushing the bytes into the databuffer directly (I know this might defeat some acceleration tricks, but I plan to deal with that later).
Now, my first surprise is that neither of the above types seem to work: Both images are displayed with a white "halo" around the transparent parts (halo more visible with PRE version). I would think that if the data is really premultiplied, reading it to a TYPE_4BYTE_ABGR_PRE buffer should just work? Or, if the data was not premultiplied, TYPE_4BYTE_ABGR should work fine? So, my next surprise. As the halo is less visible in the non-PRE version, I go with that. But now my data does not match the color model's isPremultiplied state. So I figure I should use coerceData, right? I would think that getting a colormodel identical to the one I use with the isPremultiplied set to true, and then cm.coerceData(image.getRaster(), false) would do the trick. But this ends up with the semi-transparent parts being all cyan or magenta... So, just to see the difference, I tried using image.getColorModel().coerceData(image.getRaster(), true), which I believed would do exactly the opposite of what I wanted. But then that turned out to almost remove the haloes... Which leads me to the conclusion: I simply don't get it... If someone could explain where my logic or understanding is wrong I'd be very happy! Or simply describe the way to do it right would be more than good enough! ;-) Thanks in advance, -- Harald K [Message sent by forum member 'haraldk' (haraldk)] http://forums.java.net/jive/thread.jspa?messageID=301509 =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".