fix(wow-blp): palettized BLP palette is BGRX, not 0xBBGGRR — swap R↔B#59
Merged
Merged
Conversation
The BLP2 palette colour map is stored as BGRX on disk (byte 0 = B, byte 2 = R). As a little-endian u32 this is 0x00RRGGBB. The encoder packed it as 0x00BBGGRR (R in byte 0, B in byte 2) and the decoder extracted channels to match, so round-tripping wow-blp's own output worked — but reading real Blizzard BLPs swapped red and blue. Verified against 3.3.5a client RE analysis: DecompPalFastPath copies 3 bytes from each palette entry as BGR, confirming the BGRX layout. Also corrects the doc comments on BlpRaw1 and BlpRaw3 which described the layout as 0xBBGGRR. Supersedes #52 and #58 (BLP portion). Closes #52, Closes #58
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Problem
The BLP2 palette colour map is stored as BGRX on disk (byte 0 = B, byte 1 = G, byte 2 = R, byte 3 = padding). As a little-endian u32 this is
0x00RRGGBB.The encoder packed it as
0x00BBGGRR(R in byte 0, B in byte 2) and the decoder extracted channels to match. Round-tripping wow-blp's own output worked, but reading real Blizzard BLPs swapped red and blue.Evidence
Verified against 3.3.5a client (build 12340) reverse engineering analysis:
Changes
palette.rs): Pack palette entries as0x00RRGGBB(B in byte 0, R in byte 2) matching the BGRX disk layoutraw1.rs): Extract R from bits 16–23 and B from bits 0–7 of each palette u32BlpRaw1,BlpRaw3): Corrected0xBBGGRR→0x00RRGGBBand clarified alpha is in a separate arraySupersedes