Explorar o código

Committed a patch for ARGB8 and BGRA8 support
http://hub.jmonkeyengine.org/forum/topic/support-for-argb8-and-bgra8-textures/#260706

Also made the change for Jogl TextureUtil as it was missing from the patch

git-svn-id: https://jmonkeyengine.googlecode.com/svn/branches/gradle-restructure@11085 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

rem..om %!s(int64=11) %!d(string=hai) anos
pai
achega
e69d237b51

+ 10 - 0
jme3-core/src/main/java/com/jme3/texture/Image.java

@@ -148,6 +148,16 @@ public class Image extends NativeObject implements Savable /*, Cloneable*/ {
          * 8-bit alpha, blue, green, and red.
          */
         ABGR8(32),
+
+        /**
+         * 8-bit alpha, red, blue and green
+         */
+        ARGB8(32),
+        
+        /**
+         * 8-bit blue, green, red and alpha.
+         */
+        BGRA8(32),
         
         /**
          * 16-bit red, green, blue and alpha

+ 4 - 0
jme3-core/src/main/java/com/jme3/texture/image/ImageCodec.java

@@ -134,6 +134,10 @@ abstract class ImageCodec {
         
         params.put(Format.ABGR8, new ByteOffsetImageCodec(4, 0, 0, 3, 2, 1));
         
+        params.put(Format.ARGB8, new ByteOffsetImageCodec(4, 0, 0, 1, 2, 3));
+        
+        params.put(Format.BGRA8, new ByteOffsetImageCodec(4, 0, 3, 2, 1, 0));
+        
         params.put(Format.ARGB4444, new BitMaskImageCodec(2, 0,
                                                           4, 4, 4, 4,
                                                           12, 0, 4, 8));

+ 8 - 0
jme3-desktop/src/main/java/jme3tools/converters/ImageToAwt.java

@@ -172,6 +172,14 @@ public class ImageToAwt {
         params.put(Format.RGBA8,        new DecodeParams(4, m___x, mx___, m_x__, m__x_,
                                                             s___x, sx___, s_x__, s__x_,
                                                             mxxxx, sxxxx));
+        params.put(Format.BGRA8,        new DecodeParams(4, m___x, m__x_, m_x__, mx___,
+                                                            s___x, s__x_, s_x__, sx___,
+                                                            mxxxx, sxxxx));
+
+        params.put(Format.ARGB8,        new DecodeParams(4, mx___, m_x__, m__x_, m___x,
+                                                            sx___, s_x__, s__x_, s___x,
+                                                            mxxxx, sxxxx));
+        
     }
 
     private static int Ix(int x, int y, int w){

+ 2 - 0
jme3-jogl/src/main/java/com/jme3/renderer/jogl/TextureUtil.java

@@ -123,6 +123,8 @@ public class TextureUtil {
         
         // RGB formats
         setFormat(Format.BGR8,       GL.GL_RGB8,  GL2GL3.GL_BGR, GL.GL_UNSIGNED_BYTE, false);
+        setFormat(Format.ARGB8,       GL.GL_RGBA8,  GL.GL_BGRA, GL2.GL_UNSIGNED_INT_8_8_8_8_REV, false);
+        setFormat(Format.BGRA8,       GL.GL_RGBA8,  GL.GL_BGRA, GL.GL_UNSIGNED_BYTE, false);
         setFormat(Format.RGB8,       GL.GL_RGB8,  GL.GL_RGB,        GL.GL_UNSIGNED_BYTE, false);
 //        setFormat(Format.RGB10,      GL11.GL_RGB10, GL11.GL_RGB,        GL12.GL_UNSIGNED_INT_10_10_10_2, false); 
         setFormat(Format.RGB16,      GL2GL3.GL_RGB16, GL.GL_RGB,        GL.GL_UNSIGNED_SHORT, false); 

+ 2 - 0
jme3-lwjgl/src/main/java/com/jme3/renderer/lwjgl/TextureUtil.java

@@ -107,6 +107,8 @@ class TextureUtil {
         
         // RGB formats
         setFormat(Format.BGR8,       GL11.GL_RGB8,  EXTBgra.GL_BGR_EXT, GL11.GL_UNSIGNED_BYTE, false);
+        setFormat(Format.ARGB8,       GL11.GL_RGBA8,  EXTBgra.GL_BGRA_EXT, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, false);
+        setFormat(Format.BGRA8,       GL11.GL_RGBA8,  EXTBgra.GL_BGRA_EXT, GL11.GL_UNSIGNED_BYTE, false);
         setFormat(Format.RGB8,       GL11.GL_RGB8,  GL11.GL_RGB,        GL11.GL_UNSIGNED_BYTE, false);
 //        setFormat(Format.RGB10,      GL11.GL_RGB10, GL11.GL_RGB,        GL12.GL_UNSIGNED_INT_10_10_10_2, false); 
         setFormat(Format.RGB16,      GL11.GL_RGB16, GL11.GL_RGB,        GL11.GL_UNSIGNED_SHORT, false);