parent
0db03c6faf
commit
e3a26b77a4
4 changed files with 23 additions and 5 deletions
|
|
@ -7,6 +7,7 @@
|
||||||
trials for optimizing the alpha channel, using the previously mentioned fast heuristic.
|
trials for optimizing the alpha channel, using the previously mentioned fast heuristic.
|
||||||
This option will make optimization of images with transparency somewhat slower,
|
This option will make optimization of images with transparency somewhat slower,
|
||||||
but may improve compression.
|
but may improve compression.
|
||||||
|
- Fixed a bug in reducing palettes for images with bit depth of two([#80](https://github.com/shssoichiro/oxipng/issues/80))
|
||||||
- Code cleanup
|
- Code cleanup
|
||||||
|
|
||||||
### Version 0.16.3
|
### Version 0.16.3
|
||||||
|
|
|
||||||
10
src/png.rs
10
src/png.rs
|
|
@ -543,7 +543,7 @@ impl PngData {
|
||||||
for (i, bit) in bitvec.iter().enumerate() {
|
for (i, bit) in bitvec.iter().enumerate() {
|
||||||
let mod_i = i % 4;
|
let mod_i = i % 4;
|
||||||
if bit {
|
if bit {
|
||||||
current += 2u8.pow(3u32 - mod_i as u32);
|
current += 1u8 << (3 - mod_i);
|
||||||
}
|
}
|
||||||
if mod_i == 3 {
|
if mod_i == 3 {
|
||||||
seen.insert(current);
|
seen.insert(current);
|
||||||
|
|
@ -557,7 +557,7 @@ impl PngData {
|
||||||
for (i, bit) in bitvec.iter().enumerate() {
|
for (i, bit) in bitvec.iter().enumerate() {
|
||||||
let mod_i = i % 2;
|
let mod_i = i % 2;
|
||||||
if bit {
|
if bit {
|
||||||
current += 2u8.pow(1u32 - mod_i as u32);
|
current += 1u8 << (1 - mod_i);
|
||||||
}
|
}
|
||||||
if mod_i == 1 {
|
if mod_i == 1 {
|
||||||
seen.insert(current);
|
seen.insert(current);
|
||||||
|
|
@ -649,17 +649,17 @@ impl PngData {
|
||||||
new_byte |= if let Some(new_idx) = index_map.get(&one) {
|
new_byte |= if let Some(new_idx) = index_map.get(&one) {
|
||||||
*new_idx << 6
|
*new_idx << 6
|
||||||
} else {
|
} else {
|
||||||
one << 6
|
one
|
||||||
};
|
};
|
||||||
new_byte |= if let Some(new_idx) = index_map.get(&two) {
|
new_byte |= if let Some(new_idx) = index_map.get(&two) {
|
||||||
*new_idx << 4
|
*new_idx << 4
|
||||||
} else {
|
} else {
|
||||||
two << 4
|
two
|
||||||
};
|
};
|
||||||
new_byte |= if let Some(new_idx) = index_map.get(&three) {
|
new_byte |= if let Some(new_idx) = index_map.get(&three) {
|
||||||
*new_idx << 2
|
*new_idx << 2
|
||||||
} else {
|
} else {
|
||||||
three << 2
|
three
|
||||||
};
|
};
|
||||||
new_byte |= if let Some(new_idx) = index_map.get(&four) {
|
new_byte |= if let Some(new_idx) = index_map.get(&four) {
|
||||||
*new_idx
|
*new_idx
|
||||||
|
|
|
||||||
BIN
tests/files/issue-80.png
Normal file
BIN
tests/files/issue-80.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1 KiB |
|
|
@ -274,3 +274,20 @@ fn issue_60() {
|
||||||
BitDepth::Eight,
|
BitDepth::Eight,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn issue_80() {
|
||||||
|
let input = PathBuf::from("tests/files/issue-80.png");
|
||||||
|
let opts = get_opts(&input);
|
||||||
|
let output = opts.out_file.clone();
|
||||||
|
|
||||||
|
test_it_converts(
|
||||||
|
&input,
|
||||||
|
&output,
|
||||||
|
&opts,
|
||||||
|
ColorType::Indexed,
|
||||||
|
BitDepth::Two,
|
||||||
|
ColorType::Indexed,
|
||||||
|
BitDepth::One,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue