Explorar el Código

DXTFlipper: fix incorrect flipping of DXT5 images of size 2x2
For DXT1/3 images, the format for color and alpha blocks is the same,
so the bug would not appear. For DXT5 images, the alpha block is formatted
differently. The issue is that it flips the color block and then the alpha
block for 2x2 images, but the correct order is alpha block then color block.

Kirill Vainer hace 10 años
padre
commit
10cde0a4b2
Se han modificado 1 ficheros con 12 adiciones y 11 borrados
  1. 12 11
      jme3-core/src/plugins/java/com/jme3/texture/plugins/DXTFlipper.java

+ 12 - 11
jme3-core/src/plugins/java/com/jme3/texture/plugins/DXTFlipper.java

@@ -242,21 +242,12 @@ public class DXTFlipper {
                 img.position(blockByteOffset);
                 img.limit(blockByteOffset + bpb);
 
-                img.get(colorBlock);
-                if (type == 4 || type == 5)
-                    flipDXT5Block(colorBlock, h);
-                else
-                    flipDXT1orDXTA3Block(colorBlock, h);
-
-                // write block (no need to flip block indexes, only pixels
-                // inside block
-                retImg.put(colorBlock);
-
                 if (alphaBlock != null){
                     img.get(alphaBlock);
                     switch (type){
                         case 2:
-                            flipDXT3Block(alphaBlock, h); break;
+                            flipDXT3Block(alphaBlock, h); 
+                            break;
                         case 3:
                         case 4: 
                             flipDXT5Block(alphaBlock, h);
@@ -264,6 +255,16 @@ public class DXTFlipper {
                     }
                     retImg.put(alphaBlock);
                 }
+                
+                img.get(colorBlock);
+                if (type == 4 || type == 5)
+                    flipDXT5Block(colorBlock, h);
+                else
+                    flipDXT1orDXTA3Block(colorBlock, h);
+
+                // write block (no need to flip block indexes, only pixels
+                // inside block
+                retImg.put(colorBlock);
             }
             retImg.rewind();
         }else if (h >= 4){