Skip to content
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

GFX: Add support for loading external images #101

Merged
merged 2 commits into from
May 22, 2021

Conversation

lcdr
Copy link
Contributor

@lcdr lcdr commented May 22, 2021

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 via DefineExternalImage 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 a SerializableImage. Images can be replaced with the usual file picker dialog, however changes cannot currently be saved as the setImage 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
After:
after1

Minimal testcase:
minimal.zip
before2
after2

@jindrapetrik jindrapetrik merged commit 100c3c4 into jindrapetrik:dev May 22, 2021
@jindrapetrik
Copy link
Owner

Thank you very much, you did a great job, even with samples! Cool.
This is very good pull request, I think it has everything it should have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants