Skip to content

Commit

Permalink
Lowest qualities limit number of colors
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Jan 22, 2023
1 parent 06cdae3 commit 130e04d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@ impl Writer {
100 // the first frame is too important to ruin it
};
liq.set_quality(0, quality)?;
if settings.s.quality < 50 {
liq.set_max_colors(u32::from(settings.s.quality * 2).max(16).next_power_of_two())?;
}
let (buf, width, height) = image.into_contiguous_buf();
let mut img = liq.new_image(buf, width, height, 0.)?;
// only later remapping tracks which area has been damaged by transparency
Expand Down

0 comments on commit 130e04d

Please sign in to comment.