mirror of
https://github.com/haraldk/TwelveMonkeys.git
synced 2026-05-27 00:00:02 -04:00
Microsoft Direct DrawSurface (DDS) support. (#1021)
* Basic wrapper around DDSReader.
Nasty hack to get initial plugin working...
Mark and Reset the imageinput stream when reading the header. Then read the whole buffer into DDSReader and generate a fixed BufferedImage ignoring the getDestination() BufferedImage.
* Read header (DDSHeader) and pass into DDSReader
Remove header methods using buffer offset addressing.
Switch endian for DX1-DX5 types
* Fix pixel order to ARGB
* Push ImageInputStream into DDSReader
Unable to determine buffer length (so as a hack I over allocate buffer and read)
```
byte[] buffer = new byte[width * height * 4];
int len = imageInput.read(buffer);
```
Added test files for all supported formats.
* Added processImageStarted and stubbed out processImageProgress and processReadAborted
Added all DDS format test cases to getTestData
* Remove offset and use imageInput.readFully
Reads next image calculating/updating width/height from mipmapLevel.
Probably will never get used as we only want the largest image returned.
* Code cleanup and added exception handling.
* Use Enum DDSType instead of int values.
Pass imageIndex into mipmap.
* Update imageio/imageio-dds/src/main/java/com/twelvemonkeys/imageio/plugins/dds/DDSHeader.java
Improve IIOException "Invalid DDS header size"
Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com>
* Update imageio/imageio-dds/src/main/java/com/twelvemonkeys/imageio/plugins/dds/DDSHeader.java
Improve Magic IIOException
Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com>
* Delete .run directory
* Format tabs -> 4 spaces
* Convert 4byte array into %08x string format.
* Don't need to expose classes outside the package
DDSHeader, DDSReader, DDSType
* (fix) wrong public...
* Move setByteOrder to DDSImageReader.readHeader
* Use imageIndex to calculate height/width and buffer offset.
* Delete .gitignore
* Revert "Delete .gitignore"
This reverts commit 71a4e73ca6.
* Undelete/Restore .gitignore
* Simplify String.format into one.
* Override failing tests and ignore.
* Revert formatting on PNGImageReaderTest.java
---------
Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com>
This commit is contained in:
@@ -0,0 +1,141 @@
|
||||
import com.twelvemonkeys.imageio.plugins.dds.DDSImageReader;
|
||||
import com.twelvemonkeys.imageio.plugins.dds.DDSImageReaderSpi;
|
||||
import com.twelvemonkeys.imageio.util.ImageReaderAbstractTest;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.imageio.spi.ImageReaderSpi;
|
||||
import java.awt.Dimension;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class DDSImageTeaderTest extends ImageReaderAbstractTest<DDSImageReader> {
|
||||
@Override
|
||||
protected ImageReaderSpi createProvider() {
|
||||
return new DDSImageReaderSpi();
|
||||
}
|
||||
|
||||
@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));
|
||||
|
||||
return testData;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getFormatNames() {
|
||||
return Arrays.asList("DDS", "dds");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getSuffixes() {
|
||||
return Arrays.asList("dds");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getMIMETypes() {
|
||||
return Collections.singletonList("image/vnd-ms.dds");
|
||||
}
|
||||
|
||||
/* ************************************************************************************************************* *
|
||||
* IGNORE Broken Tests...
|
||||
* ************************************************************************************************************* */
|
||||
|
||||
@Ignore("Known issue: currently not supported in DDS")
|
||||
@Test
|
||||
@Override
|
||||
public void testGetNumImagesNoInput() throws IOException {
|
||||
super.testGetNumImagesNoInput();
|
||||
}
|
||||
|
||||
@Ignore("Known issue: currently not supported in DDS")
|
||||
@Test
|
||||
@Override
|
||||
public void testAffineTransformOpCompatibility() throws IOException {
|
||||
super.testAffineTransformOpCompatibility();
|
||||
}
|
||||
|
||||
@Ignore("Known issue: currently not supported in DDS")
|
||||
@Test
|
||||
@Override
|
||||
public void testReadWithSourceRegionParam() throws IOException {
|
||||
super.testReadWithSourceRegionParam();
|
||||
}
|
||||
|
||||
@Ignore("Known issue: currently not supported in DDS")
|
||||
@Test
|
||||
@Override
|
||||
public void testReadWithSourceRegionParamEqualImage() throws IOException {
|
||||
super.testReadWithSourceRegionParamEqualImage();
|
||||
}
|
||||
|
||||
@Ignore("Known issue: currently not supported in DDS")
|
||||
@Test
|
||||
@Override
|
||||
public void testReadWithSubsampleAndSourceRegionParam() throws IOException {
|
||||
super.testReadWithSubsampleAndSourceRegionParam();
|
||||
}
|
||||
|
||||
@Ignore("Known issue: currently not supported in DDS")
|
||||
@Test
|
||||
@Override
|
||||
public void testReadWithSubsampleParamDimensions() throws IOException {
|
||||
super.testReadWithSubsampleParamDimensions();
|
||||
}
|
||||
|
||||
@Ignore("Known issue: currently not supported in DDS")
|
||||
@Test
|
||||
@Override
|
||||
public void testReadWithSubsampleParamPixels() throws IOException {
|
||||
super.testReadWithSubsampleParamPixels();
|
||||
}
|
||||
|
||||
@Ignore("Known issue: currently not supported in DDS")
|
||||
@Test
|
||||
@Override
|
||||
public void testSetDestination() throws IOException {
|
||||
super.testSetDestination();
|
||||
}
|
||||
|
||||
@Ignore("Known issue: currently not supported in DDS")
|
||||
@Test
|
||||
@Override
|
||||
public void testSetDestinationIllegal() throws IOException {
|
||||
super.testSetDestinationIllegal();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user