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.
Summary
Add support for rendering
.mdp
thumbnails.Fixes #1145
File layout
Mostly translated from the repo linked below.
The first 20 bytes are a binary header called
TMDIPack
.After the binary header comes an XML header called
MDI
.The relevant bits are the
Thumb
element and its attributes as well as the amount ofLayer
elements.After the XML comes the
MDIBIN
which holds the embedded thumbnail as well as the actual project data.The
MDIBIN
contains with a 132-byteTPackerHeader
followed by a blob of data whose length is specified in the header.This repeats for each layer as well as the thumbnail.
The
TPackerHeader
looks like thisThe thumbnail is stored as a continious blob of BGRA image data whose dimensions are specified in the attributes of the
Thumb
element in the XML header.I think the thumbnail is always the first block in the
MDIBIN
, but I couldn't find anything explicitly saying so.While the thumbnail is in BGRA, it doesn't seem to store any transparency data. It always shows up with a solid white background, even in Windows explorer.

I also wanted to document the format in the code, but I always ended up with a docstring several times the size of the actual implementation, so I left it out.
Before
After
Sources for the file format
I Got most of the info from this repo. It's in Japanese, so I translated it via Deepl. It also gets one thig wrong, namely the color mode of the thumbnail. It claims its in ARGB, when it's actually in BGRA. I found that out via this GIMP plugin for
.mdp
filesFile used for testing
layers-color-transparency.zip
Zipped because of GitHub upload limitations,
Tasks Completed