Bug 724 - Loading transparent PNG without alpha channel into Texture
Summary: Loading transparent PNG without alpha channel into Texture
Status: RESOLVED FIXED
Alias: None
Product: Jogl
Classification: JogAmp
Component: util (show other bugs)
Version: 2
Hardware: All all
: --- major
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2013-04-24 14:56 CEST by Alan Sambol
Modified: 2013-07-03 11:50 CEST (History)
1 user (show)

See Also:
Type: ---
SCM Refs:
35fcf49d1cb49e3844e7cee44f34d827d8a102ce 51427b92a2d9cd3fc619854e26536c9c6adad947 f0c8d6cf5d7f8f64cea79b3d0d27e4db6ccef41e
Workaround: ---


Attachments
Original PNG. Contains transparent background. Created in Adobe Photoshop. (2.08 KB, image/png)
2013-04-24 14:56 CEST, Alan Sambol
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Sambol 2013-04-24 14:56:45 CEST
Created attachment 456 [details]
Original PNG. Contains transparent background. Created in Adobe Photoshop.

Loading the texture via following command doesn't work properly:
TextureIO.newTexture(getClass().getClassLoader().getResource("original.png"), false, "png");

Result can be seen here: http://forum.jogamp.org/file/n4029016/bar-left-rendered.png (don't mind the blue line and rotation, it's from another png).
It turns out yellow instead of gray.

If I use the following command it works fine:
BufferedImage img = ImageIO.read(getClass().getClassLoader().getResource("original.png"));
TextureIO.newTexture(AWTTextureIO.newTextureData(GLProfile.getDefault(), img, false));

The problem is I can't use AWTTextureIO on Android, which is one of our target platforms.

The original image is in attachment. It's a default png image created in Adobe Photoshop - with transparent background and no alpha channel - used for web and Jogl1 with no problems.
Comment 1 Sven Gothel 2013-07-03 11:50:01 CEST
1 Add manual unit test, incr. PNGImage verbosity.

2 PNGJ: Bump to git sha1 a0b1101ba2d37de39428ed55c8189502e24a3125 
  of https://code.google.com/p/pngj/

3 Testing PNG Transparency / Fixing GLSL Shader of test case: 
   Mix texture alpha properly (pre-multiply), due to lack of ALPHA_BLENDING.

'Works for me' .. i.e. w/ fixed GLSL shader respecting texture alpha,
the GL readBuffer produced the right data.

I don't think [2] has anything todo w/ it - but I don't like to test again.

Thank you for the test case (image), it is incl. in our unit tests now [1 and 3].
You might want to tune your shader code, or enable ALPHA blending ?!