From 629c007cd42455664c0d1443a286f7a99158e9dd Mon Sep 17 00:00:00 2001 From: shadowislord Date: Tue, 10 Feb 2015 20:16:51 -0500 Subject: [PATCH] DDSLoader: fix loading 16-bit images (as exported by PVRTexTool) --- .../com/jme3/texture/plugins/DDSLoader.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/jme3-core/src/plugins/java/com/jme3/texture/plugins/DDSLoader.java b/jme3-core/src/plugins/java/com/jme3/texture/plugins/DDSLoader.java index e4e046ed5..e7ef0bcd9 100644 --- a/jme3-core/src/plugins/java/com/jme3/texture/plugins/DDSLoader.java +++ b/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 { int dxgiFormat = in.readInt(); if (dxgiFormat == 0) { - pixelFormat = Format.ETC1; - bpp = 4; + pixelFormat = Format.ETC1; + bpp = 4; } else { - throw new IOException("Unsupported DX10 format: " + dxgiFormat); + throw new IOException("Unsupported DX10 format: " + dxgiFormat); } compressed = true; - + int resDim = in.readInt(); if (resDim == DX10DIM_TEXTURE3D) { texture3D = true; @@ -327,9 +327,17 @@ public class DDSLoader implements AssetLoader { if (is(pfFlags, DDPF_RGB)) { if (is(pfFlags, DDPF_ALPHAPIXELS)) { - pixelFormat = Format.RGBA8; + if (bpp == 16) { + pixelFormat = Format.RGB5A1; + } else { + pixelFormat = Format.RGBA8; + } } else { - pixelFormat = Format.RGB8; + if (bpp == 16) { + pixelFormat = Format.RGB565; + } else { + pixelFormat = Format.RGB8; + } } } else if (is(pfFlags, DDPF_GRAYSCALE) && is(pfFlags, DDPF_ALPHAPIXELS)) { switch (bpp) {