mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 09:31:34 +11:00
Fix alpha not being considered when transparent_colour was absent (#377)
Previously `include_image!()` would only set transparent pixels to index 0 if a `transparent_color` was specified. However, this in unnecessary as the transparency index is always 0. - [X] Changelog updated / no changelog update needed
This commit is contained in:
commit
2b91cb8773
|
@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Alpha channel is now considered by `include_gfx!()` even when `transparent_colour` is absent.
|
||||||
|
|
||||||
## [0.13.0] - 2023/01/19
|
## [0.13.0] - 2023/01/19
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -386,7 +386,7 @@ fn add_image_to_tile_data(
|
||||||
for i in inner_x * 8..inner_x * 8 + 8 {
|
for i in inner_x * 8..inner_x * 8 + 8 {
|
||||||
let colour = image.colour(x * tile_size + i, y * tile_size + j);
|
let colour = image.colour(x * tile_size + i, y * tile_size + j);
|
||||||
tile_data
|
tile_data
|
||||||
.push(palette.colour_index(colour, optimiser.transparent_colour));
|
.push(palette.colour_index(colour));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,15 +41,15 @@ impl Palette16 {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn colour_index(&self, colour: Colour, transparent_colour: Option<Colour>) -> u8 {
|
pub fn colour_index(&self, colour: Colour) -> u8 {
|
||||||
let colour_to_search = match (transparent_colour, colour.is_transparent()) {
|
// A transparent color is always index 0
|
||||||
(Some(transparent_colour), true) => transparent_colour,
|
if colour.is_transparent() {
|
||||||
_ => colour,
|
return 0;
|
||||||
};
|
}
|
||||||
|
|
||||||
self.colours
|
self.colours
|
||||||
.iter()
|
.iter()
|
||||||
.position(|c| *c == colour_to_search)
|
.position(|c| *c == colour)
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
panic!(
|
panic!(
|
||||||
"Can't get a colour index without it existing, looking for {:?}, got {:?}",
|
"Can't get a colour index without it existing, looking for {:?}, got {:?}",
|
||||||
|
|
Loading…
Reference in a new issue