File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -414,9 +414,8 @@ pub fn unpremultiply_la16(in_place: &mut [u16], bit_depth: u32) {
414414 for chunk in in_place. chunks_exact_mut ( 2 ) {
415415 let a = chunk[ 1 ] as u32 ;
416416 if a != 0 {
417- let a_recip = 1. / a as f32 ;
418- chunk[ 0 ] = ( ( chunk[ 0 ] as u32 * max_colors) as f32 * a_recip) as u16 ;
419- chunk[ 1 ] = ( ( a * max_colors) as f32 * a_recip) as u16 ;
417+ let a_recip = max_colors as f32 / a as f32 ;
418+ chunk[ 0 ] = ( chunk[ 0 ] as f32 * a_recip) as u16 ;
420419 }
421420 }
422421}
@@ -443,7 +442,6 @@ pub fn unpremultiply_rgba16(in_place: &mut [u16], bit_depth: u32) {
443442 chunk[ 0 ] = ( chunk[ 0 ] as f32 * a_recip) as u16 ;
444443 chunk[ 1 ] = ( chunk[ 1 ] as f32 * a_recip) as u16 ;
445444 chunk[ 2 ] = ( chunk[ 2 ] as f32 * a_recip) as u16 ;
446- chunk[ 3 ] = ( a as f32 * a_recip) as u16 ;
447445 }
448446 }
449447}
You can’t perform that action at this time.
0 commit comments