@@ -126,9 +126,9 @@ private void Find_nn(Pnnbin[] bins, int idx, bool texicab)
126126 protected override QuanFn GetQuanFn ( int nMaxColors , short quan_rt ) {
127127 if ( quan_rt > 0 ) {
128128 if ( quan_rt > 1 )
129- return cnt => ( int ) Math . Pow ( cnt , .75 ) ;
129+ return cnt => ( float ) Math . Pow ( cnt , .75 ) ;
130130 if ( nMaxColors < 64 )
131- return cnt => ( int ) Math . Sqrt ( cnt ) ;
131+ return cnt => ( float ) Math . Sqrt ( cnt ) ;
132132
133133 return cnt => ( float ) Math . Sqrt ( cnt ) ;
134134 }
@@ -630,7 +630,7 @@ internal Bitmap QuantizeImage(int[] pixels, int bitmapWidth, int nMaxColors, boo
630630 var bitmapHeight = pixels . Length / bitmapWidth ;
631631
632632 var dest = new Bitmap ( bitmapWidth , bitmapHeight , pixelFormat ) ;
633- if ( m_palette == null ) {
633+ if ( m_palette == null ) {
634634 var palettes = dest . Palette . Entries ;
635635 if ( palettes . Length != nMaxColors )
636636 palettes = new Color [ nMaxColors ] ;
@@ -655,15 +655,6 @@ internal Bitmap QuantizeImage(int[] pixels, int bitmapWidth, int nMaxColors, boo
655655
656656 var qPixels = Dither ( pixels , m_palette , bitmapWidth , bitmapHeight , dither ) ;
657657
658- if ( HasAlpha && nMaxColors <= 256 )
659- {
660- var k = qPixels [ m_transparentPixelIndex ] ;
661- if ( nMaxColors > 2 )
662- m_palette [ k ] = m_transparentColor ;
663- else if ( m_palette [ k ] != m_transparentColor )
664- BitmapUtilities . Swap ( ref m_palette [ 0 ] , ref m_palette [ 1 ] ) ;
665- }
666-
667658 if ( nMaxColors > 256 )
668659 return BitmapUtilities . ProcessImagePixels ( dest , qPixels , hasSemiTransparency , m_transparentPixelIndex ) ;
669660
0 commit comments