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

DDS parsing and exporting #1285

Open
heinezen opened this issue Aug 23, 2020 · 8 comments
Open

DDS parsing and exporting #1285

heinezen opened this issue Aug 23, 2020 · 8 comments
Labels
area: assets Involved with assets (images, sounds, ...) good first issue Suitable for newcomers lang: cython Implemented using Cython code lang: python Done in Python code
Projects

Comments

@heinezen
Copy link
Member

heinezen commented Aug 23, 2020

Required skills: Python, Cython

Difficulty: Medium

DDS files are used to store terrain textures in the Definitive Editions of AoE1 and AoE2. We will need to convert them to PNG so that they can be used by openage. pillow supports DDS, but their parser is written in Python. For maximum speedup, we should implement A parser written in Cython with Python glue code to attach it to the converter.

Renderdoc has a C++ implementation of a DDS parser that we could use as an inspiration

Further Reading

@heinezen heinezen added area: assets Involved with assets (images, sounds, ...) good first issue Suitable for newcomers lang: python Done in Python code labels Aug 23, 2020
@heinezen heinezen added this to output in convert Aug 23, 2020
@sandsmark
Copy link
Contributor

I guess you don't need a fully fledged DDS converter, iirc. they use one of the simpler encodings.

@TobiasFP
Copy link
Contributor

Another source of inspiration could be:
https://code.google.com/archive/p/gimp-dds/source#

@heinezen heinezen pinned this issue Nov 18, 2020
@TobiasFP
Copy link
Contributor

TobiasFP commented Nov 18, 2020

@heinezen Do you know if there is any reason we cannot simply use wand?
Do we want to avoid more dependencies?

I tested wand with this small script, using a file from DEII:
prerequisities: pip3 install wand
It seams to even use cython in the backbone of it, so it should be performant enough.

from wand import image

def main():
    with image.Image(filename='input/002_50730.DDS') as img:
        with img.convert('png') as converted:
            converted.save(filename='output/002_50730.png')
if __name__ == "__main__":
    # execute only if run as a script
    main()

@heinezen
Copy link
Member Author

heinezen commented Nov 18, 2020

@TobiasFP It require imagemagick, does it? If so, I'd rather not use wand because it introduces a pretty heavy dependency for something that is essentially only required when the converter runs (which is ideally only used once during the setup phase). We would also have to bundle it for the Windows builds.

So good idea because it would simplify it for us, but imagemagick has to much overhead imo :D

@TobiasFP
Copy link
Contributor

TobiasFP commented Nov 18, 2020

Yeah, that was what i thought too.
Pillow also support dds, which is written in python, but i don't think it is very optimised/not using cython, so it might be too slow.
But would that be less of a problem since it is all python?

If not, the dds importer would be of tremendous help writing the parser (and listed under a cc0 license).

https://github.com/python-pillow/Pillow

@heinezen
Copy link
Member Author

I see that pillow extended their DDS support which is nice :) Although it is probably still slow.

I've added a link to pillow's code to the initial post. We could use their implementation, but then we miss out on PNG optimization and speed. I would still prefer a fast Cython implementation.

@TobiasFP
Copy link
Contributor

Do we have an estimate when the dds2png library is necessary to push on?
If we need it quite soon, i suggest we implement pillow for now (Since it would take so little time), and get back to the proper dds2png library when it becomes important improve speed.

If you think this is the wrong way to go, I will gladly begin on the cython implementation, but it will take quite a while to finish, as I do not have much spare time.

I see that pillow extended their DDS support which is nice :) Although it is probably still slow.

I've added a link to pillow's code to the initial post. We could use their implementation, but then we miss out on PNG optimization and speed. I would still prefer a fast Cython implementation.

@heinezen
Copy link
Member Author

@TobiasFP It is not strictly necessary, but using pillow is better than no support. We can implement this issue using pillow and leave it open until the Cython implementation is ready :)

@heinezen heinezen added the hacktoberfest For newcomers from Hacktoberfest event label Sep 30, 2021
@heinezen heinezen removed the hacktoberfest For newcomers from Hacktoberfest event label Nov 9, 2021
@heinezen heinezen added the lang: cython Implemented using Cython code label Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: assets Involved with assets (images, sounds, ...) good first issue Suitable for newcomers lang: cython Implemented using Cython code lang: python Done in Python code
Projects
Status: converter
Status: 🔖 TODO
convert
  
output
Development

No branches or pull requests

3 participants