From 89fa56241dd43aeec59807976c83e6d58bc54011 Mon Sep 17 00:00:00 2001 From: Benign X <1341398182@qq.com> Date: Wed, 1 May 2024 15:40:02 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=81(NewQuant):=20add=20color=5Fmap=5Fa?= =?UTF-8?q?lpha=20for=20the=20tRNS=20trunc=20in=20the=20PNG=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Benign X <1341398182@qq.com> --- src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 2bb408b..136ac50 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -235,6 +235,16 @@ impl NeuQuant { map } + /// Return the Alpha channel of the color map calculated from the sample. + /// It's useful for transparency used in the tRNS chunk of the PNG format. + pub fn color_map_alpha(&self) -> Vec { + let mut map = Vec::with_capacity(self.netsize); + for entry in &self.colormap { + map.push(entry.a as u8); + } + map + } + /// Move neuron i towards biased (a,b,g,r) by factor alpha fn salter_single(&mut self, alpha: f64, i: i32, quad: Quad) { let n = &mut self.network[i as usize];