@@ -142,11 +142,15 @@ int unpack_pixel(anim_instance *ai, ubyte *data, ubyte pix, int aabitmap, int bp
142142 bit_16 = (ushort)pix;
143143 break ;
144144 case 8 :
145- // 8 bit-per-pixel aa bitmaps are a bit special since they only use a palette index value in the range [0, 15]. These
146- // palette indexes must be remapped to alpha values between [0, 255] which is what graphics code expects. Palette
147- // range [0, 14] is a gradient from black to white, and palette index 15 is a special color which indicates the background
148- // area of a HUD gauge. Retail code uses the final alpha value for index 1 for this special index to give gauges a dark
149- // transparent background.
145+ // 8-bit-per-pixel HUD gauge ANI aabitmaps use the palette index directly as an alpha value —
146+ // the actual RGB colors stored in the palette are completely ignored. The valid range is [0, 15]:
147+ // [0]: fully transparent (alpha 0)
148+ // [1-14]: black-to-white gradient (alpha = index * 18)
149+ // [15]: special HUD background (alpha 18, matching index 1, for a dark transparent tint)
150+ // [>15]: clamped to fully opaque (alpha 255)
151+ // Because only the index value matters, the palette in the source file must be ordered so that
152+ // index 0 is the transparent end and index 14 is the opaque end. A reversed palette causes the
153+ // gauge to render as a solid white square (see GitHub issue #4148).
150154 if (pix > 15 ) {
151155 bit_8 = 255 ;
152156 }
@@ -240,11 +244,15 @@ int unpack_pixel_count(anim_instance *ai, ubyte *data, ubyte pix, int count = 0,
240244 bit_16 = (ushort)pix;
241245 break ;
242246 case 8 :
243- // 8 bit-per-pixel aa bitmaps are a bit special since they only use a palette index value in the range [0, 15]. These
244- // palette indexes must be remapped to alpha values between [0, 255] which is what graphics code expects. Palette
245- // range [0, 14] is a gradient from black to white, and palette index 15 is a special color which indicates the background
246- // area of a HUD gauge. Retail code uses the final alpha value for index 1 for this special index to give gauges a dark
247- // transparent background.
247+ // 8-bit-per-pixel HUD gauge ANI aabitmaps use the palette index directly as an alpha value —
248+ // the actual RGB colors stored in the palette are completely ignored. The valid range is [0, 15]:
249+ // [0]: fully transparent (alpha 0)
250+ // [1-14]: black-to-white gradient (alpha = index * 18)
251+ // [15]: special HUD background (alpha 18, matching index 1, for a dark transparent tint)
252+ // [>15]: clamped to fully opaque (alpha 255)
253+ // Because only the index value matters, the palette in the source file must be ordered so that
254+ // index 0 is the transparent end and index 14 is the opaque end. A reversed palette causes the
255+ // gauge to render as a solid white square (see GitHub issue #4148).
248256 if (pix > 15 ) {
249257 bit_8 = 255 ;
250258 }
0 commit comments