Repository navigation
fix(dds): keep the colours of DDS pictures inside other files - #745
Merged
KnifeLemon merged 1 commit intoOct 29, 2026
Merged
Conversation
E-book pictures, DOCX and HWPX output and glTF textures decode an embedded DDS with ImageMagick and re-encode it as PNG, so they came out with red and blue swapped. Call DdsChannelOrder.Correct there as well, add a byte overload for textures, and reject headers shorter than 128 bytes before reading them. Closes KnifeLemon#741
KnifeLemon
approved these changes
Oct 29, 2026
KnifeLemon
left a comment
Owner
There was a problem hiding this comment.
Thanks, @SeoJCalive! All four places now go through DdsChannelOrder.Correct, the byte overload shares the header check, and the short-header guard keeps broken bytes from being read. The arm64 failure on the first run was StallWatchTests, a timing test unrelated to this change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this change?
Closes #741. Follow-up to #627, as asked there.
DDS pictures inside other files now keep their colours. Each of these places decodes an embedded DDS with ImageMagick and re-encodes it as PNG, but without the red/blue correction that standalone DDS conversion and the crop window have had since #627. They now call
DdsChannelOrder.Correctright after reading the image:EbookFiles.CommonImageDocxWriter.WritePackageHwpxWriter.WritePackageGltfFormat.TextureForGltfglTF textures come as bytes, not a file, so
DdsChannelOrdergets aCorrect(ReadOnlySpan<byte>, image)overload. It shares the header check and the existing probes with the file version. The sharedLayoutOfnow returns "not this layout" for anything shorter than the 128-byte header before it reads a field, so short or broken bytes are never corrected and never throw.Not in this PR:
.svgname inHtmlReader.ddsType of change
How was it tested?
dotnet format --verify-no-changes: no changes. Build warnings are the same as on main.dotnet test: new tests for MD→EPUB, MD→DOCX, MD→HWPX and OBJ/MTL→GLB, each for both alpha flags, read the real output PNG and check that every RGB pixel matches the source red. Byte tests check that null, empty, 1 to 127 byte and malformed headers get no swap, and that the byte and file checks agree. Removing any one of the four newCorrectcalls fails its test with blue instead of red. Dropping the length guard or always swapping fails the byte tests.Full Engines, Core and App tests on Linux (Release): the failures are the same by name as on main on this machine (rhwp needs a newer glibc, LibreOffice and FFmpeg codec setup, and one engines page check). Only the 11 new tests were added, and they pass.
Screenshots (UI changes)
No UI change.
Checklist
src/Filee.App/Assets/i18n/*.jsonfiles (none)THIRD-PARTY-NOTICES.md(none)