ScreenShot image -> ".png" but not include alpha value
so modify LWJGLRenderer and JOGLRenderer .class
Index: src/com/jme/renderer/lwjgl/LWJGLRenderer.java
===================================================================
--- src/com/jme/renderer/lwjgl/LWJGLRenderer.java (revision 4087)
+++ src/com/jme/renderer/lwjgl/LWJGLRenderer.java (working copy)
@@ -615,10 +615,10 @@
// Create a pointer to the image info and create a buffered image to
// hold it.
- ByteBuffer buff = BufferUtils.createByteBuffer(width * height * 3);
- grabScreenContents(buff, Image.Format.RGB8, 0, 0, width, height);
+ ByteBuffer buff = BufferUtils.createByteBuffer(width * height * 4);
+ grabScreenContents(buff, Image.Format.RGBA8, 0, 0, width, height);
BufferedImage img = new BufferedImage(width, height,
- BufferedImage.TYPE_INT_RGB);
+ BufferedImage.TYPE_INT_ARGB);
// Grab each pixel information and set it to the BufferedImage info.
for (int x = 0; x < width; x++) {
@@ -624,10 +624,16 @@
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
- int index = 3 * ((height - y - 1) * width + x);
- int argb = (((int) (buff.get(index+0)) & 0xFF) << 16) //r
- | (((int) (buff.get(index+1)) & 0xFF) << 8) //g
- | (((int) (buff.get(index+2)) & 0xFF)); //b
+ int index = 4 * ((height - y - 1) * width + x);
+ int r = ((int) (buff.get(index+0)));
+ int g = ((int) (buff.get(index+1)));
+ int b = ((int) (buff.get(index+2)));
+ int a = ((int) (buff.get(index+3)));
+
+ int argb = ((a & 0xFF) << 24) //a
+ | ((r & 0xFF) << 16) //r
+ | ((g & 0xFF) << 8) //g
+ | ((b & 0xFF)); //b
img.setRGB(x, y, argb);
}
Index: src/com/jme/renderer/jogl/JOGLRenderer.java
===================================================================
--- src/com/jme/renderer/jogl/JOGLRenderer.java (revision 4087)
+++ src/com/jme/renderer/jogl/JOGLRenderer.java (working copy)
@@ -636,10 +636,10 @@
// Create a pointer to the image info and create a buffered image to
// hold it.
- ByteBuffer buff = BufferUtils.createByteBuffer(width * height * 3);
- grabScreenContents(buff, Image.Format.RGB8, 0, 0, width, height);
+ ByteBuffer buff = BufferUtils.createByteBuffer(width * height * 4);
+ grabScreenContents(buff, Image.Format.RGBA8, 0, 0, width, height);
BufferedImage img = new BufferedImage(width, height,
- BufferedImage.TYPE_INT_RGB);
+ BufferedImage.TYPE_INT_ARGB);
// Grab each pixel information and set it to the BufferedImage info.
for (int x = 0; x < width; x++) {
@@ -645,10 +645,16 @@
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
- int index = 3 * ((height - y - 1) * width + x);
- int argb = (((int) (buff.get(index+0)) & 0xFF) << 16) //r
- | (((int) (buff.get(index+1)) & 0xFF) << 8) //g
- | (((int) (buff.get(index+2)) & 0xFF)); //b
+ int index = 4 * ((height - y - 1) * width + x);
+ int r = ((int) (buff.get(index+0)));
+ int g = ((int) (buff.get(index+1)));
+ int b = ((int) (buff.get(index+2)));
+ int a = ((int) (buff.get(index+3)));
+
+ int argb = ((a & 0xFF) << 24) //a
+ | ((r & 0xFF) << 16) //r
+ | ((g & 0xFF) << 8) //g
+ | ((b & 0xFF)); //b
img.setRGB(x, y, argb);
}