From a5c8af67adab9ff6d1b4e486c41ab91ddfe0863b Mon Sep 17 00:00:00 2001 From: gered Date: Mon, 20 Mar 2023 22:18:02 -0400 Subject: [PATCH] set alpha component consistently with other colours during palette read when reading palette files/streams, we set up the colour entries using helper functions that automatically set an alpha component of 255. however, we were first initializing the palette with 0 (alpha component of 0 too). this meant that if a palette of less than 256 colours was loaded, the remaining entries (since Palette is always sized for 256 colours), were black (0,0,0) with alpha components of 0. this change makes all palette entries have a consistent alpha value (which is never really used anyway ...) when loaded. --- ggdt/src/graphics/palette.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ggdt/src/graphics/palette.rs b/ggdt/src/graphics/palette.rs index 0961c4c..808b8be 100644 --- a/ggdt/src/graphics/palette.rs +++ b/ggdt/src/graphics/palette.rs @@ -8,7 +8,7 @@ use byteorder::{ReadBytesExt, WriteBytesExt}; use thiserror::Error; use crate::graphics::bitmap::indexed::IndexedBitmap; -use crate::graphics::color::{from_rgb32, lerp_rgb32, to_rgb32}; +use crate::graphics::color::{from_rgb32, lerp_rgb32, to_argb32, to_rgb32}; use crate::NUM_COLORS; use crate::utils::abs_diff; @@ -26,7 +26,7 @@ fn read_palette_6bit( if num_colors > NUM_COLORS { return Err(PaletteError::OutOfRange(num_colors)); } - let mut colors = [0u32; NUM_COLORS]; + let mut colors = [to_argb32(255, 0, 0, 0); NUM_COLORS]; for i in 0..num_colors { let r = reader.read_u8()?; let g = reader.read_u8()?; @@ -62,7 +62,7 @@ fn read_palette_8bit( if num_colors > NUM_COLORS { return Err(PaletteError::OutOfRange(num_colors)); } - let mut colors = [0u32; NUM_COLORS]; + let mut colors = [to_argb32(255, 0, 0, 0); NUM_COLORS]; for i in 0..num_colors { let r = reader.read_u8()?; let g = reader.read_u8()?;