Format tabs -> 4 spaces

This commit is contained in:
Paul Allen
2024-09-24 10:39:12 +01:00
parent 53356e7a24
commit bcfab45977
9 changed files with 840 additions and 842 deletions

View File

@@ -1,15 +1,15 @@
package com.twelvemonkeys.imageio.plugins.dds;
interface DDS {
byte[] MAGIC = new byte[]{'D', 'D', 'S', ' '};
int HEADER_SIZE = 124;
byte[] MAGIC = new byte[]{'D', 'D', 'S', ' '};
int HEADER_SIZE = 124;
int FLAG_CAPS = 0x1; // Required in every .dds file.
int FLAG_HEIGHT = 0x2; // Required in every .dds file.
int FLAG_WIDTH = 0x4; // Required in every .dds file.
int FLAG_PITCH = 0x8; // Required when pitch is provided for an uncompressed texture.
int FLAG_PIXELFORMAT = 0x1000; // Required in every .dds file.
int FLAG_MIPMAPCOUNT = 0x20000; // Required in a mipmapped texture.
int FLAG_LINEARSIZE = 0x80000; // Required when pitch is provided for a compressed texture.
int FLAG_DEPTH = 0x800000; // Required in a depth texture.
int FLAG_CAPS = 0x1; // Required in every .dds file.
int FLAG_HEIGHT = 0x2; // Required in every .dds file.
int FLAG_WIDTH = 0x4; // Required in every .dds file.
int FLAG_PITCH = 0x8; // Required when pitch is provided for an uncompressed texture.
int FLAG_PIXELFORMAT = 0x1000; // Required in every .dds file.
int FLAG_MIPMAPCOUNT = 0x20000; // Required in a mipmapped texture.
int FLAG_LINEARSIZE = 0x80000; // Required when pitch is provided for a compressed texture.
int FLAG_DEPTH = 0x800000; // Required in a depth texture.
}

View File

@@ -8,134 +8,134 @@ import java.util.Arrays;
public final class DDSHeader {
// https://learn.microsoft.com/en-us/windows/win32/direct3ddds/dx-graphics-dds-pguide
private int flags;
private int width;
private int height;
private int mipmap;
// https://learn.microsoft.com/en-us/windows/win32/direct3ddds/dx-graphics-dds-pguide
private int flags;
private int width;
private int height;
private int mipmap;
private int pixelFormatFlags;
private int fourCC;
private int bitCount;
private int redMask;
private int greenMask;
private int blueMask;
private int alphaMask;
private int pixelFormatFlags;
private int fourCC;
private int bitCount;
private int redMask;
private int greenMask;
private int blueMask;
private int alphaMask;
public static DDSHeader read(final ImageInputStream imageInput) throws IOException {
DDSHeader header = new DDSHeader();
public static DDSHeader read(final ImageInputStream imageInput) throws IOException {
DDSHeader header = new DDSHeader();
imageInput.setByteOrder(ByteOrder.LITTLE_ENDIAN);
imageInput.setByteOrder(ByteOrder.LITTLE_ENDIAN);
// Read MAGIC bytes [0,3]
byte[] magic = new byte[DDS.MAGIC.length];
imageInput.readFully(magic);
if (!Arrays.equals(DDS.MAGIC, magic)) {
throw new IIOException(String.format("Not a DDS file. Expected DDS magic %02x, read %02x", DDS.MAGIC, magic));
}
// Read MAGIC bytes [0,3]
byte[] magic = new byte[DDS.MAGIC.length];
imageInput.readFully(magic);
if (!Arrays.equals(DDS.MAGIC, magic)) {
throw new IIOException(String.format("Not a DDS file. Expected DDS magic %02x, read %02x", Arrays.toString(DDS.MAGIC), magic));
}
// DDS_HEADER structure
// https://learn.microsoft.com/en-us/windows/win32/direct3ddds/dds-header
int dwSize = imageInput.readInt(); // [4,7]
if (dwSize != DDS.HEADER_SIZE) {
throw new IIOException(String.format("Invalid DDS header size (expected %d): %d", DDS.HEADER_SIZE, dwSize);
}
// DDS_HEADER structure
// https://learn.microsoft.com/en-us/windows/win32/direct3ddds/dds-header
int dwSize = imageInput.readInt(); // [4,7]
if (dwSize != DDS.HEADER_SIZE) {
throw new IIOException(String.format("Invalid DDS header size (expected %d): %d", DDS.HEADER_SIZE, dwSize));
}
// Verify flags
header.flags = imageInput.readInt(); // [8,11]
if (header.getFlag(DDS.FLAG_CAPS
& DDS.FLAG_HEIGHT
& DDS.FLAG_WIDTH
& DDS.FLAG_PIXELFORMAT)) {
throw new IIOException("Required DDS Flag missing in header: " + Integer.toHexString(header.flags));
}
// Verify flags
header.flags = imageInput.readInt(); // [8,11]
if (header.getFlag(DDS.FLAG_CAPS
& DDS.FLAG_HEIGHT
& DDS.FLAG_WIDTH
& DDS.FLAG_PIXELFORMAT)) {
throw new IIOException("Required DDS Flag missing in header: " + Integer.toHexString(header.flags));
}
// Read Height & Width
header.height = imageInput.readInt(); // [12,15]
header.width = imageInput.readInt(); // [16,19]
// Read Height & Width
header.height = imageInput.readInt(); // [12,15]
header.width = imageInput.readInt(); // [16,19]
int dwPitchOrLinearSize = imageInput.readInt(); // [20,23]
int dwDepth = imageInput.readInt(); // [24,27]
header.mipmap = imageInput.readInt(); // [28,31]
int dwPitchOrLinearSize = imageInput.readInt(); // [20,23]
int dwDepth = imageInput.readInt(); // [24,27]
header.mipmap = imageInput.readInt(); // [28,31]
byte[] dwReserved1 = new byte[11 * 4]; // [32,75]
imageInput.readFully(dwReserved1);
byte[] dwReserved1 = new byte[11 * 4]; // [32,75]
imageInput.readFully(dwReserved1);
// DDS_PIXELFORMAT structure
int px_dwSize = imageInput.readInt(); // [76,79]
// DDS_PIXELFORMAT structure
int px_dwSize = imageInput.readInt(); // [76,79]
header.pixelFormatFlags = imageInput.readInt(); // [80,83]
header.fourCC = imageInput.readInt(); // [84,87]
header.bitCount = imageInput.readInt(); // [88,91]
header.redMask = imageInput.readInt(); // [92,95]
header.greenMask = imageInput.readInt(); // [96,99]
header.blueMask = imageInput.readInt(); // [100,103]
header.alphaMask = imageInput.readInt(); // [104,107]
header.pixelFormatFlags = imageInput.readInt(); // [80,83]
header.fourCC = imageInput.readInt(); // [84,87]
header.bitCount = imageInput.readInt(); // [88,91]
header.redMask = imageInput.readInt(); // [92,95]
header.greenMask = imageInput.readInt(); // [96,99]
header.blueMask = imageInput.readInt(); // [100,103]
header.alphaMask = imageInput.readInt(); // [104,107]
int dwCaps = imageInput.readInt(); // [108,111]
int dwCaps2 = imageInput.readInt(); // [112,115]
int dwCaps3 = imageInput.readInt(); // [116,119]
int dwCaps4 = imageInput.readInt(); // [120,123]
int dwCaps = imageInput.readInt(); // [108,111]
int dwCaps2 = imageInput.readInt(); // [112,115]
int dwCaps3 = imageInput.readInt(); // [116,119]
int dwCaps4 = imageInput.readInt(); // [120,123]
int dwReserved2 = imageInput.readInt(); // [124,127]
int dwReserved2 = imageInput.readInt(); // [124,127]
return header;
}
return header;
}
private boolean getFlag(int mask) {
return (flags & mask) != 0;
}
private boolean getFlag(int mask) {
return (flags & mask) != 0;
}
public int getWidth() {
return width;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public void setHeight(int height) {
this.height = height;
}
public int getMipmap() {
return mipmap;
}
public int getMipmap() {
return mipmap;
}
public int getAlphaMask() {
return alphaMask;
}
public int getAlphaMask() {
return alphaMask;
}
public int getBitCount() {
return bitCount;
}
public int getBitCount() {
return bitCount;
}
public int getBlueMask() {
return blueMask;
}
public int getBlueMask() {
return blueMask;
}
public int getFlags() {
return flags;
}
public int getFlags() {
return flags;
}
public int getFourCC() {
return fourCC;
}
public int getFourCC() {
return fourCC;
}
public int getGreenMask() {
return greenMask;
}
public int getGreenMask() {
return greenMask;
}
public int getPixelFormatFlags() {
return pixelFormatFlags;
}
public int getPixelFormatFlags() {
return pixelFormatFlags;
}
public int getRedMask() {
return redMask;
}
public int getRedMask() {
return redMask;
}
}

View File

@@ -17,123 +17,123 @@ import java.util.List;
public final class DDSImageReader extends ImageReaderBase {
private DDSHeader header;
private DDSHeader header;
public DDSImageReader(final ImageReaderSpi provider) {
super(provider);
}
public DDSImageReader(final ImageReaderSpi provider) {
super(provider);
}
@Override
protected void resetMembers() {
header = null;
}
@Override
protected void resetMembers() {
header = null;
}
@Override
public int getWidth(final int imageIndex) throws IOException {
checkBounds(imageIndex);
readHeader();
@Override
public int getWidth(final int imageIndex) throws IOException {
checkBounds(imageIndex);
readHeader();
return header.getWidth();
}
return header.getWidth();
}
@Override
public int getHeight(int imageIndex) throws IOException {
checkBounds(imageIndex);
readHeader();
@Override
public int getHeight(int imageIndex) throws IOException {
checkBounds(imageIndex);
readHeader();
return header.getHeight();
}
return header.getHeight();
}
@Override
public ImageTypeSpecifier getRawImageType(int imageIndex) throws IOException {
checkBounds(imageIndex);
readHeader();
@Override
public ImageTypeSpecifier getRawImageType(int imageIndex) throws IOException {
checkBounds(imageIndex);
readHeader();
return ImageTypeSpecifiers.createFromBufferedImageType(BufferedImage.TYPE_INT_ARGB);
}
return ImageTypeSpecifiers.createFromBufferedImageType(BufferedImage.TYPE_INT_ARGB);
}
@Override
public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex) throws IOException {
return Collections.singletonList(getRawImageType(imageIndex)).iterator();
}
@Override
public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex) throws IOException {
return Collections.singletonList(getRawImageType(imageIndex)).iterator();
}
@Override
public BufferedImage read(int imageIndex, ImageReadParam param) throws IOException {
checkBounds(imageIndex);
readHeader();
@Override
public BufferedImage read(int imageIndex, ImageReadParam param) throws IOException {
checkBounds(imageIndex);
readHeader();
processImageStarted(imageIndex);
processImageStarted(imageIndex);
DDSReader dds = new DDSReader(header);
int[] pixels = dds.read(imageInput, imageIndex);
DDSReader dds = new DDSReader(header);
int[] pixels = dds.read(imageInput, imageIndex);
int width = getWidth(imageIndex);
int height = getHeight(imageIndex);
int width = getWidth(imageIndex);
int height = getHeight(imageIndex);
BufferedImage destination = getDestination(param, getImageTypes(imageIndex), width, height);
destination.setRGB(0, 0, width, height, pixels, 0, width);
BufferedImage destination = getDestination(param, getImageTypes(imageIndex), width, height);
destination.setRGB(0, 0, width, height, pixels, 0, width);
// TODO: break read into raster line and add progress and abort checks
processImageProgress(100f);
if (abortRequested()) {
processReadAborted();
}
// TODO: break read into raster line and add progress and abort checks
processImageProgress(100f);
if (abortRequested()) {
processReadAborted();
}
processImageComplete();
processImageComplete();
return destination;
}
return destination;
}
private void readHeader() throws IOException {
if (header == null) {
header = DDSHeader.read(imageInput);
private void readHeader() throws IOException {
if (header == null) {
header = DDSHeader.read(imageInput);
imageInput.flushBefore(imageInput.getStreamPosition());
}
imageInput.flushBefore(imageInput.getStreamPosition());
}
imageInput.seek(imageInput.getFlushedPosition());
}
imageInput.seek(imageInput.getFlushedPosition());
}
public static void main(final String[] args) throws IOException {
public static void main(final String[] args) throws IOException {
String parentDir = "imageio/imageio-dds/src/test/resources/dds";
String parentDir = "imageio/imageio-dds/src/test/resources/dds";
List<File> testFiles = new ArrayList<>();
testFiles.add(new File(parentDir, "dds_A1R5G5B5.dds"));
testFiles.add(new File(parentDir, "dds_A1R5G5B5_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_A4R4G4B4.dds"));
testFiles.add(new File(parentDir, "dds_A4R4G4B4_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_A8B8G8R8.dds"));
testFiles.add(new File(parentDir, "dds_A8B8G8R8_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_A8R8G8B8.dds"));
testFiles.add(new File(parentDir, "dds_A8R8G8B8_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_DXT1.dds"));
testFiles.add(new File(parentDir, "dds_DXT1_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_DXT2.dds"));
testFiles.add(new File(parentDir, "dds_DXT2_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_DXT3.dds"));
testFiles.add(new File(parentDir, "dds_DXT3_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_DXT4.dds"));
testFiles.add(new File(parentDir, "dds_DXT4_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_DXT5.dds"));
testFiles.add(new File(parentDir, "dds_DXT5_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_R5G6B5.dds"));
testFiles.add(new File(parentDir, "dds_R5G6B5_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_R8G8B8.dds"));
testFiles.add(new File(parentDir, "dds_R8G8B8_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_X1R5G5B5.dds"));
testFiles.add(new File(parentDir, "dds_X1R5G5B5_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_X4R4G4B4.dds"));
testFiles.add(new File(parentDir, "dds_X4R4G4B4_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_X8B8G8R8.dds"));
testFiles.add(new File(parentDir, "dds_X8B8G8R8_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_X8R8G8B8.dds"));
testFiles.add(new File(parentDir, "dds_X8R8G8B8_mipmap.dds"));
List<File> testFiles = new ArrayList<>();
testFiles.add(new File(parentDir, "dds_A1R5G5B5.dds"));
testFiles.add(new File(parentDir, "dds_A1R5G5B5_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_A4R4G4B4.dds"));
testFiles.add(new File(parentDir, "dds_A4R4G4B4_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_A8B8G8R8.dds"));
testFiles.add(new File(parentDir, "dds_A8B8G8R8_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_A8R8G8B8.dds"));
testFiles.add(new File(parentDir, "dds_A8R8G8B8_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_DXT1.dds"));
testFiles.add(new File(parentDir, "dds_DXT1_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_DXT2.dds"));
testFiles.add(new File(parentDir, "dds_DXT2_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_DXT3.dds"));
testFiles.add(new File(parentDir, "dds_DXT3_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_DXT4.dds"));
testFiles.add(new File(parentDir, "dds_DXT4_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_DXT5.dds"));
testFiles.add(new File(parentDir, "dds_DXT5_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_R5G6B5.dds"));
testFiles.add(new File(parentDir, "dds_R5G6B5_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_R8G8B8.dds"));
testFiles.add(new File(parentDir, "dds_R8G8B8_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_X1R5G5B5.dds"));
testFiles.add(new File(parentDir, "dds_X1R5G5B5_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_X4R4G4B4.dds"));
testFiles.add(new File(parentDir, "dds_X4R4G4B4_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_X8B8G8R8.dds"));
testFiles.add(new File(parentDir, "dds_X8B8G8R8_mipmap.dds"));
testFiles.add(new File(parentDir, "dds_X8R8G8B8.dds"));
testFiles.add(new File(parentDir, "dds_X8R8G8B8_mipmap.dds"));
for (File file : testFiles) {
BufferedImage image = ImageIO.read(file);
showIt(image, file.getName());
}
for (File file : testFiles) {
BufferedImage image = ImageIO.read(file);
showIt(image, file.getName());
}
}
}
}

View File

@@ -10,37 +10,37 @@ import java.util.Locale;
public final class DDSImageReaderSpi extends ImageReaderSpiBase {
public DDSImageReaderSpi() {
super(new DDSProviderInfo());
}
public DDSImageReaderSpi() {
super(new DDSProviderInfo());
}
@Override
public boolean canDecodeInput(final Object source) throws IOException {
if (!(source instanceof ImageInputStream)) {
return false;
}
@Override
public boolean canDecodeInput(final Object source) throws IOException {
if (!(source instanceof ImageInputStream)) {
return false;
}
ImageInputStream stream = (ImageInputStream) source;
ImageInputStream stream = (ImageInputStream) source;
stream.mark();
stream.mark();
try {
byte[] magic = new byte[DDS.MAGIC.length];
stream.readFully(magic);
try {
byte[] magic = new byte[DDS.MAGIC.length];
stream.readFully(magic);
return Arrays.equals(DDS.MAGIC, magic);
} finally {
stream.reset();
}
}
return Arrays.equals(DDS.MAGIC, magic);
} finally {
stream.reset();
}
}
@Override
public ImageReader createReaderInstance(Object extension) throws IOException {
return new DDSImageReader(this);
}
@Override
public ImageReader createReaderInstance(Object extension) throws IOException {
return new DDSImageReader(this);
}
@Override
public String getDescription(Locale locale) {
return "Direct DrawSurface (DDS) Image Reader";
}
@Override
public String getDescription(Locale locale) {
return "Direct DrawSurface (DDS) Image Reader";
}
}

View File

@@ -3,18 +3,18 @@ package com.twelvemonkeys.imageio.plugins.dds;
import com.twelvemonkeys.imageio.spi.ReaderWriterProviderInfo;
final class DDSProviderInfo extends ReaderWriterProviderInfo {
DDSProviderInfo() {
super(
DDSProviderInfo.class,
new String[] {"DDS", "dds"},
new String[] {"dds"},
new String[] {"image/vnd-ms.dds"},
"com.twelvemonkeys.imageio.plugins.dds.DDSImageReader",
new String[]{"com.twelvemonkeys.imageio.plugins.dds.DDSImageReaderSpi"},
null,
null,
false, null, null, null, null,
true, null, null, null, null
);
}
DDSProviderInfo() {
super(
DDSProviderInfo.class,
new String[]{"DDS", "dds"},
new String[]{"dds"},
new String[]{"image/vnd-ms.dds"},
"com.twelvemonkeys.imageio.plugins.dds.DDSImageReader",
new String[]{"com.twelvemonkeys.imageio.plugins.dds.DDSImageReaderSpi"},
null,
null,
false, null, null, null, null,
true, null, null, null, null
);
}
}

View File

@@ -4,38 +4,38 @@ import javax.imageio.IIOException;
public enum DDSType {
DXT1(0x31545844),
DXT2(0x32545844),
DXT3(0x33545844),
DXT4(0x34545844),
DXT5(0x35545844),
A1R5G5B5((1 << 16) | 2),
X1R5G5B5((2 << 16) | 2),
A4R4G4B4((3 << 16) | 2),
X4R4G4B4((4 << 16) | 2),
R5G6B5((5 << 16) | 2),
R8G8B8((1 << 16) | 3),
A8B8G8R8((1 << 16) | 4),
X8B8G8R8((2 << 16) | 4),
A8R8G8B8((3 << 16) | 4),
X8R8G8B8((4 << 16) | 4);
DXT1(0x31545844),
DXT2(0x32545844),
DXT3(0x33545844),
DXT4(0x34545844),
DXT5(0x35545844),
A1R5G5B5((1 << 16) | 2),
X1R5G5B5((2 << 16) | 2),
A4R4G4B4((3 << 16) | 2),
X4R4G4B4((4 << 16) | 2),
R5G6B5((5 << 16) | 2),
R8G8B8((1 << 16) | 3),
A8B8G8R8((1 << 16) | 4),
X8B8G8R8((2 << 16) | 4),
A8R8G8B8((3 << 16) | 4),
X8R8G8B8((4 << 16) | 4);
private final int value;
private final int value;
DDSType(int value) {
this.value = value;
}
DDSType(int value) {
this.value = value;
}
public int value() {
return value;
}
public int value() {
return value;
}
public static DDSType parse(int type) throws IIOException {
for (DDSType t : DDSType.values()) {
if (type == t.value()) {
return t;
}
}
throw new IIOException("Unknown type: " + Integer.toHexString(type));
}
public static DDSType parse(int type) throws IIOException {
for (DDSType t : DDSType.values()) {
if (type == t.value()) {
return t;
}
}
throw new IIOException("Unknown type: " + Integer.toHexString(type));
}
}

View File

@@ -10,62 +10,62 @@ import java.util.Collections;
import java.util.List;
public class DDSImageTeaderTest extends ImageReaderAbstractTest<DDSImageReader> {
@Override
protected ImageReaderSpi createProvider() {
return new DDSImageReaderSpi();
}
@Override
protected ImageReaderSpi createProvider() {
return new DDSImageReaderSpi();
}
@Override
protected List<TestData> getTestData() {
Dimension dim = new Dimension(256, 256);
@Override
protected List<TestData> getTestData() {
Dimension dim = new Dimension(256, 256);
List<TestData> testData = new ArrayList<>();
testData.add(new TestData(getClassLoaderResource("/dds/dds_A1R5G5B5.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_A1R5G5B5_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_A4R4G4B4.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_A4R4G4B4_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_A8B8G8R8.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_A8B8G8R8_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_A8R8G8B8.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_A8R8G8B8_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT1.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT1_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT2.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT2_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT3.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT3_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT4.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT4_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT5.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT5_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_R5G6B5.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_R5G6B5_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_R8G8B8.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_R8G8B8_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_X1R5G5B5.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_X1R5G5B5_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_X4R4G4B4.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_X4R4G4B4_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_X8B8G8R8.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_X8B8G8R8_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_X8R8G8B8.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_X8R8G8B8_mipmap.dds"), dim));
List<TestData> testData = new ArrayList<>();
testData.add(new TestData(getClassLoaderResource("/dds/dds_A1R5G5B5.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_A1R5G5B5_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_A4R4G4B4.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_A4R4G4B4_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_A8B8G8R8.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_A8B8G8R8_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_A8R8G8B8.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_A8R8G8B8_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT1.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT1_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT2.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT2_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT3.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT3_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT4.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT4_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT5.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_DXT5_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_R5G6B5.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_R5G6B5_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_R8G8B8.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_R8G8B8_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_X1R5G5B5.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_X1R5G5B5_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_X4R4G4B4.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_X4R4G4B4_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_X8B8G8R8.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_X8B8G8R8_mipmap.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_X8R8G8B8.dds"), dim));
testData.add(new TestData(getClassLoaderResource("/dds/dds_X8R8G8B8_mipmap.dds"), dim));
return testData;
}
return testData;
}
@Override
protected List<String> getFormatNames() {
return Arrays.asList("DDS", "dds");
}
@Override
protected List<String> getFormatNames() {
return Arrays.asList("DDS", "dds");
}
@Override
protected List<String> getSuffixes() {
return Arrays.asList("dds");
}
@Override
protected List<String> getSuffixes() {
return Arrays.asList("dds");
}
@Override
protected List<String> getMIMETypes() {
return Collections.singletonList("image/vnd-ms.dds");
}
@Override
protected List<String> getMIMETypes() {
return Collections.singletonList("image/vnd-ms.dds");
}
}

View File

@@ -30,16 +30,15 @@
package com.twelvemonkeys.imageio.reference;
import com.sun.imageio.plugins.png.PNGImageReader;
import com.twelvemonkeys.imageio.util.IIOUtil;
import com.twelvemonkeys.imageio.util.ImageReaderAbstractTest;
import com.sun.imageio.plugins.png.PNGImageReader;
import org.junit.Test;
import javax.imageio.IIOException;
import javax.imageio.spi.IIORegistry;
import javax.imageio.spi.ImageReaderSpi;
import java.awt.*;
import java.awt.Dimension;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
@@ -86,8 +85,7 @@ public class PNGImageReaderTest extends ImageReaderAbstractTest<PNGImageReader>
public void testSetDestinationTypeIllegal() throws IOException {
try {
super.testSetDestinationTypeIllegal();
}
catch (IIOException expected) {
} catch (IIOException expected) {
// Known bug
}
}