GFX: Add support for loading external images #101
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
GFX files have the ability to reference external images through the
DefineExternalImage
tag. In the current FFDec, this tag is only parsed, but does not have image functionality like the other image tags. Also, the parsing is incorrect, with FFDec missing a string in the tag. This PR fixes the parsing and adds support for loading external DDS images viaDefineExternalImage
tags.In order to support the loading of DDS files, the library DDSReader (licensed under MIT) is added as a dependency. Using this library, the referenced images are read to a
BufferedImage
, scaled to their target dimensions, and stored as aSerializableImage
. Images can be replaced with the usual file picker dialog, however changes cannot currently be saved as thesetImage
function does not have access to the file path which would be needed to reference an external image (and silently changing the tag type to an internal image seemed to me like the wrong way of doing things).I wasn't sure whether I should add an entry for DDS files in the format enum, so the image format is reported as PNG for now.
This is my first time contributing to this codebase, so I'm not sure whether I did everything the right way. I can make changes if requested.
Examples:
Before:
![before1](https://user-images.githubusercontent.com/19377567/119226066-c63d3f80-bb07-11eb-9f3a-b1b1b9e7b771.PNG)
![after1](https://user-images.githubusercontent.com/19377567/119226082-d2c19800-bb07-11eb-8721-316be27c52de.PNG)
After:
Minimal testcase:
![before2](https://user-images.githubusercontent.com/19377567/119226121-ecfb7600-bb07-11eb-840e-bb5c4e53bd44.PNG)
![after2](https://user-images.githubusercontent.com/19377567/119226122-ee2ca300-bb07-11eb-978b-84f1b1140d43.PNG)
minimal.zip