Fix alpha up and down
This commit is contained in:
parent
8396a262c3
commit
5429f63227
1 changed files with 4 additions and 2 deletions
|
|
@ -108,7 +108,7 @@ fn reduced_alpha_to_up(png: &PngImage, bpc: usize, bpp: usize) -> Vec<u8> {
|
||||||
current_line.extend_from_slice(pixel);
|
current_line.extend_from_slice(pixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
last_line = current_line.clone();
|
last_line = current_line[1..current_line.len()].to_vec();
|
||||||
lines.push(current_line.clone());
|
lines.push(current_line.clone());
|
||||||
current_line.clear();
|
current_line.clear();
|
||||||
}
|
}
|
||||||
|
|
@ -118,6 +118,7 @@ fn reduced_alpha_to_up(png: &PngImage, bpc: usize, bpp: usize) -> Vec<u8> {
|
||||||
fn reduced_alpha_to_down(png: &PngImage, bpc: usize, bpp: usize) -> Vec<u8> {
|
fn reduced_alpha_to_down(png: &PngImage, bpc: usize, bpp: usize) -> Vec<u8> {
|
||||||
let mut reduced = Vec::with_capacity(png.data.len());
|
let mut reduced = Vec::with_capacity(png.data.len());
|
||||||
let mut last_line = Vec::new();
|
let mut last_line = Vec::new();
|
||||||
|
let mut pos = 0;
|
||||||
for line in png.scan_lines() {
|
for line in png.scan_lines() {
|
||||||
if line.data.len() != last_line.len() {
|
if line.data.len() != last_line.len() {
|
||||||
last_line = vec![0; line.data.len()];
|
last_line = vec![0; line.data.len()];
|
||||||
|
|
@ -131,7 +132,8 @@ fn reduced_alpha_to_down(png: &PngImage, bpc: usize, bpp: usize) -> Vec<u8> {
|
||||||
reduced.extend_from_slice(pixel);
|
reduced.extend_from_slice(pixel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
last_line = reduced.clone();
|
last_line = reduced[(pos + 1)..reduced.len()].to_vec();
|
||||||
|
pos = reduced.len();
|
||||||
}
|
}
|
||||||
reduced
|
reduced
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue