-
-
Notifications
You must be signed in to change notification settings - Fork 317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Microsoft Direct DrawSurface (DDS) support. #1021
Conversation
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.
Remove header methods using buffer offset addressing. Switch endian for DX1-DX5 types
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.
…ocessReadAborted Added all DDS format test cases to getTestData
Reads next image calculating/updating width/height from mipmapLevel. Probably will never get used as we only want the largest image returned.
Pass imageIndex into mipmap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all! Great work, this is a very nice addition! 👍
I have made some comments, inline in the code.
In addition, the code base uses 4 spaces indents, but your code seems to use tabs. I will have to ask you to change this. 😀
imageio/imageio-dds/src/main/java/com/twelvemonkeys/imageio/plugins/dds/DDSHeader.java
Outdated
Show resolved
Hide resolved
imageio/imageio-dds/src/main/java/com/twelvemonkeys/imageio/plugins/dds/DDSHeader.java
Outdated
Show resolved
Hide resolved
imageio/imageio-dds/src/main/java/com/twelvemonkeys/imageio/plugins/dds/DDSImageReader.java
Outdated
Show resolved
Hide resolved
imageio/imageio-dds/src/main/java/com/twelvemonkeys/imageio/plugins/dds/DDSReader.java
Outdated
Show resolved
Hide resolved
imageio/imageio-dds/src/main/java/com/twelvemonkeys/imageio/plugins/dds/DDSHeader.java
Outdated
Show resolved
Hide resolved
imageio/imageio-dds/src/main/java/com/twelvemonkeys/imageio/plugins/dds/DDSType.java
Outdated
Show resolved
Hide resolved
imageio/imageio-dds/src/main/java/com/twelvemonkeys/imageio/plugins/dds/DDSHeader.java
Outdated
Show resolved
Hide resolved
imageio/imageio-dds/src/main/java/com/twelvemonkeys/imageio/plugins/dds/DDSHeader.java
Outdated
Show resolved
Hide resolved
…ugins/dds/DDSHeader.java Improve IIOException "Invalid DDS header size" Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com>
…ugins/dds/DDSHeader.java Improve Magic IIOException Co-authored-by: Harald Kuhr <harald.kuhr@gmail.com>
DDSHeader, DDSReader, DDSType
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 %s, read %s", String.format("%08x", new BigInteger(1, DDS.MAGIC)), String.format("%08x", new BigInteger(1, magic)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I forgot that the magic was a byte array, not an int...
I think, however, this should work:
throw new IIOException(String.format("Not a DDS file. Expected DDS magic %s, read %s", String.format("%08x", new BigInteger(1, DDS.MAGIC)), String.format("%08x", new BigInteger(1, magic)))); | |
throw new IIOException(String.format("Not a DDS file. Expected DDS magic %08x, read %08x", new BigInteger(1, DDS.MAGIC), new BigInteger(1, magic))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did something similar...
String.format("%08x", new BigInteger(1, magic))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but that is 3 String.format
s instead of 1...
I think that addresses all of your review items; do let me know if I missed anything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent.
Almost there! Promise! 😀
If you can just revert the .gitignore
file to what it was before, add some @Ingore
s to all the failing tests, and clean up some String.format
s, we're good to go!
Awsome work!
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 %s, read %s", String.format("%08x", new BigInteger(1, DDS.MAGIC)), String.format("%08x", new BigInteger(1, magic)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but that is 3 String.format
s instead of 1...
.../imageio-reference/src/test/java/com/twelvemonkeys/imageio/reference/PNGImageReaderTest.java
Outdated
Show resolved
Hide resolved
Thank you! Great work! I'll merge later today, when all the checks have passed and I have some spare time! 😀 |
Thank you for reviewing this change and merging to main. I look forward to using it when you have time to update/release. If you need any additional help please let me know. |
Initial implementation of Microsoft Direct DrawSurface (DDS) support.
DDS reader is based on https://github.com/npedotnet/DDSReader