From 43279e72c3360110c1d890449b7592fdcbbc012e Mon Sep 17 00:00:00 2001 From: Eievui <14899090+eievui5@users.noreply.github.com> Date: Sat, 21 Jan 2023 14:12:56 -0500 Subject: [PATCH 1/2] Fix alpha not being considered when transparent_colour was absent --- agb-image-converter/src/lib.rs | 2 +- agb-image-converter/src/palette16.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/agb-image-converter/src/lib.rs b/agb-image-converter/src/lib.rs index 656a9bcb..a6472f50 100644 --- a/agb-image-converter/src/lib.rs +++ b/agb-image-converter/src/lib.rs @@ -386,7 +386,7 @@ fn add_image_to_tile_data( for i in inner_x * 8..inner_x * 8 + 8 { let colour = image.colour(x * tile_size + i, y * tile_size + j); tile_data - .push(palette.colour_index(colour, optimiser.transparent_colour)); + .push(palette.colour_index(colour)); } } } diff --git a/agb-image-converter/src/palette16.rs b/agb-image-converter/src/palette16.rs index 2878bad6..2d384c69 100644 --- a/agb-image-converter/src/palette16.rs +++ b/agb-image-converter/src/palette16.rs @@ -41,15 +41,15 @@ impl Palette16 { true } - pub fn colour_index(&self, colour: Colour, transparent_colour: Option) -> u8 { - let colour_to_search = match (transparent_colour, colour.is_transparent()) { - (Some(transparent_colour), true) => transparent_colour, - _ => colour, - }; + pub fn colour_index(&self, colour: Colour) -> u8 { + // A transparent color is always index 0 + if colour.is_transparent() { + return 0; + } self.colours .iter() - .position(|c| *c == colour_to_search) + .position(|c| *c == colour) .unwrap_or_else(|| { panic!( "Can't get a colour index without it existing, looking for {:?}, got {:?}", From 09cf9601212d5614e89066b11bab5eb4b23f5b51 Mon Sep 17 00:00:00 2001 From: Eievui <14899090+eievui5@users.noreply.github.com> Date: Sat, 21 Jan 2023 14:14:43 -0500 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f784d369..d53b3977 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed +- Alpha channel is now considered by `include_gfx!()` even when `transparent_colour` is absent. + ## [0.13.0] - 2023/01/19 ### Added