parent
ff7a9547c3
commit
041c433ccb
3 changed files with 17 additions and 2 deletions
|
|
@ -29,8 +29,11 @@ pub fn reduce_alpha_channel(png: &mut PngData, channels: u8) -> Option<Vec<u8>>
|
|||
// sBIT contains information about alpha channel's original depth,
|
||||
// and alpha has just been removed
|
||||
if let Some(sbit_header) = png.aux_headers.get_mut(b"sBIT") {
|
||||
assert_eq!(sbit_header.len(), channels as usize);
|
||||
sbit_header.pop();
|
||||
// Some programs save the sBIT header as RGB even if the image is RGBA.
|
||||
// Only remove the alpha channel if it's actually there.
|
||||
if sbit_header.len() == channels as usize {
|
||||
sbit_header.pop();
|
||||
}
|
||||
}
|
||||
|
||||
Some(reduced)
|
||||
|
|
|
|||
BIN
tests/files/issue-141.png
Normal file
BIN
tests/files/issue-141.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 MiB |
|
|
@ -548,3 +548,15 @@ fn issue_140() {
|
|||
BitDepth::Two,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_141() {
|
||||
test_it_converts(
|
||||
"tests/files/issue-141.png",
|
||||
None,
|
||||
ColorType::RGBA,
|
||||
BitDepth::Eight,
|
||||
ColorType::RGB,
|
||||
BitDepth::Eight,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue