Long story short I have premultiplied Texture. I grab a FrameBuffer, clear it with (0,0,0,0), set the blend mode to glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA)
, and render the Texture. Then I grab the pixels glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, byteBufferPixels);
and use that:
BufferedImage screenshot = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
screenshot.setRGB(0, 0, width, height, argbInts, 0, width);
try {
ImageIO.write(screenshot, "png", file);
} catch (IOException e) {
e.printStackTrace();
}
I also have tried BufferedImage.TYPE_INT_ARGB_PRE
with no change.
The result is this:
How do I get a nice transparent PNG file out of premultiplied pixel data in OpenGL?
Thanks!