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.
experimental
Kirill Vainer 10 years ago
parent aba48495e1
commit 10cde0a4b2
  1. 23
      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){

Loading…
Cancel
Save