Add support for ASTC compressed KTX textures#35
Open
Erik-White wants to merge 29 commits intoSixLabors:mainfrom
Open
Add support for ASTC compressed KTX textures#35Erik-White wants to merge 29 commits intoSixLabors:mainfrom
Erik-White wants to merge 29 commits intoSixLabors:mainfrom
Conversation
Erik-White
commented
Feb 13, 2026
| // Seek to the end of the file to ensure the entire stream is consumed. | ||
| // KTX2 files use byte offsets for mipmap data, so the stream position may not | ||
| // be at the end after reading. We need to find the furthest point read. | ||
| if (levelIndices.Length > 0) |
Contributor
Author
There was a problem hiding this comment.
This is just to satisfy the tests that check the stream has been read to the end. The reader can jump around a bit in the file so it may not always end up positioned at the end otherwise.
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.
Prerequisites
Description
Adds support for decoding ASTC compressed KTX and KTX2 textures. A major challenge was finding a suitable ASTC decoder, I eventually decided to implement my own: https://github.com/Erik-White/AstcSharp
Most of the actual implementation is in the ASTC decoder, the changes in ImageSharp.Textures mostly just pass through to the decoder.
KTX1 has support for ASTC, but I couldn't find a tool to create test images and had a difficult time sourcing test data. So the tests are quite limited for v1, but much better for KTX2.
Limitations
Test data
Everything used is either created by myself, or sourced from
https://github.com/KhronosGroup/KTX-Software (Apache 2.0 license)
https://github.com/KhronosGroup/KTX-Software-CTS (Apache 2.0 license)
https://github.com/ARM-software/astc-encoder (Apache-2.0 license)