DDSLoader: fix loading 16-bit images (as exported by PVRTexTool)

experimental
shadowislord 10 years ago
parent badefdf4e4
commit 629c007cd4
  1. 20
      jme3-core/src/plugins/java/com/jme3/texture/plugins/DDSLoader.java

@ -151,13 +151,13 @@ public class DDSLoader implements AssetLoader {
private void loadDX10Header() throws IOException { private void loadDX10Header() throws IOException {
int dxgiFormat = in.readInt(); int dxgiFormat = in.readInt();
if (dxgiFormat == 0) { if (dxgiFormat == 0) {
pixelFormat = Format.ETC1; pixelFormat = Format.ETC1;
bpp = 4; bpp = 4;
} else { } else {
throw new IOException("Unsupported DX10 format: " + dxgiFormat); throw new IOException("Unsupported DX10 format: " + dxgiFormat);
} }
compressed = true; compressed = true;
int resDim = in.readInt(); int resDim = in.readInt();
if (resDim == DX10DIM_TEXTURE3D) { if (resDim == DX10DIM_TEXTURE3D) {
texture3D = true; texture3D = true;
@ -327,9 +327,17 @@ public class DDSLoader implements AssetLoader {
if (is(pfFlags, DDPF_RGB)) { if (is(pfFlags, DDPF_RGB)) {
if (is(pfFlags, DDPF_ALPHAPIXELS)) { if (is(pfFlags, DDPF_ALPHAPIXELS)) {
pixelFormat = Format.RGBA8; if (bpp == 16) {
pixelFormat = Format.RGB5A1;
} else {
pixelFormat = Format.RGBA8;
}
} else { } else {
pixelFormat = Format.RGB8; if (bpp == 16) {
pixelFormat = Format.RGB565;
} else {
pixelFormat = Format.RGB8;
}
} }
} else if (is(pfFlags, DDPF_GRAYSCALE) && is(pfFlags, DDPF_ALPHAPIXELS)) { } else if (is(pfFlags, DDPF_GRAYSCALE) && is(pfFlags, DDPF_ALPHAPIXELS)) {
switch (bpp) { switch (bpp) {

Loading…
Cancel
Save