Skip to content

fix(wow-blp): palettized BLP palette is BGRX, not 0xBBGGRR — swap R↔B#59

Merged
danielsreichenbach merged 1 commit into
mainfrom
fix/blp-palette-bgrx-channel-order
Jun 8, 2026
Merged

fix(wow-blp): palettized BLP palette is BGRX, not 0xBBGGRR — swap R↔B#59
danielsreichenbach merged 1 commit into
mainfrom
fix/blp-palette-bgrx-channel-order

Conversation

@danielsreichenbach

@danielsreichenbach danielsreichenbach commented Jun 8, 2026

Copy link
Copy Markdown
Member

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:

DecompPalFastPath copies 3 bytes from each palette entry as BGR, confirming the palette format is BGRX (blue, green, red, padding), not BGRA.

Changes

  • Encoder (palette.rs): Pack palette entries as 0x00RRGGBB (B in byte 0, R in byte 2) matching the BGRX disk layout
  • Decoder (raw1.rs): Extract R from bits 16–23 and B from bits 0–7 of each palette u32
  • Doc comments (BlpRaw1, BlpRaw3): Corrected 0xBBGGRR0x00RRGGBB and clarified alpha is in a separate array

Supersedes

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

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
file-formats/graphics/wow-blp/src/convert/raw1.rs 0.00% 12 Missing ⚠️
...le-formats/graphics/wow-blp/src/convert/palette.rs 0.00% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

@danielsreichenbach danielsreichenbach merged commit a6b7ce8 into main Jun 8, 2026
12 of 16 checks passed
@danielsreichenbach danielsreichenbach deleted the fix/blp-palette-bgrx-channel-order branch June 8, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant