예제 #1
0
        public override void CloneDataFromRead(PngChunk other)
        {
            PngChunkPLTE otherx = (PngChunkPLTE)other;

            this.SetNentries(otherx.GetNentries());
            System.Array.Copy((Array)(otherx.entries), 0, (Array)(entries), 0, nentries);
        }
예제 #2
0
        public override void CloneDataFromRead(PngChunk other)
        {
            PngChunkPLTE pngChunkPLTE = (PngChunkPLTE)other;

            SetNentries(pngChunkPLTE.GetNentries());
            Array.Copy(pngChunkPLTE.entries, 0, entries, 0, nentries);
        }
예제 #3
0
        public PngChunkPLTE CreatePLTEChunk()
        {
            PngChunkPLTE plte = new PngChunkPLTE(chunkList.imageInfo);

            QueueChunk(plte);
            return(plte);
        }
예제 #4
0
        private void CloneData(PngChunkPLTE other)
        {
            if (other is null)
            {
                throw new System.ArgumentNullException(nameof(other));
            }

            SetNentries(other.GetNentries());
            System.Array.Copy(other.entries, 0, entries, 0, nentries);
        }
    bool ReadPalette( PngChunkPLTE _palette )
    {
        int[] rgb = new int[ 4 ];
        int c;
        for( c=0; c<m_coloursInPalette; c++ )
        {
            int c2 = c;
            if( m_config.m_colorRemapSourceToDest.ContainsKey( c ))
                c2 = m_config.m_colorRemapSourceToDest[ c ];

            _palette.GetEntryRgb( c2, rgb );
            float fr = ((float)rgb[ 0 ]) / 255.0f;
            float fg = ((float)rgb[ 1 ]) / 255.0f;
            float fb = ((float)rgb[ 2 ]) / 255.0f;
            //float fa = ((float)a) / 255.0f;
            float fa = 1.0f;

            /*
            if((c%16) == 0 )
                fa = 0.0f;
            else
                fa = 1.0f;
                */

            Color col = new Color( fr, fg, fb, fa );
            m_palette.Add( col );
            m_colorUsed.Add( false );
        }

        while( c < 16 )
        {
            m_palette.Add( new Color( 1.0f, 0.0f, 1.0f, 1.0f ));
            m_colorUsed.Add( false );
            c++;
        }

        return true;
    }
예제 #6
0
 public static int[] Palette2rgb( ImageLine line, PngChunkPLTE pal, PngChunkTRNS trns, int [] buf )
 {
     bool isalpha = trns != null;
     int channels = isalpha ? 4 : 3;
     int nsamples = line.ImgInfo.Cols * channels;
     if ( buf == null || buf.Length < nsamples )
         buf = new int [ nsamples ];
     if ( !line.SamplesUnpacked )
         line = line.unpackToNewImageLine ();
     bool isbyte = line.SampleType == Hjg.Pngcs.ImageLine.ESampleType.BYTE;
     int nindexesWithAlpha = trns != null ? trns.GetPalletteAlpha ().Length : 0;
     for ( int c = 0; c < line.ImgInfo.Cols; c++ )
     {
         int index = isbyte ? ( line.ScanlineB [ c ] & 0xFF ) : line.Scanline [ c ];
         pal.GetEntryRgb ( index, buf, c * channels );
         if ( isalpha )
         {
             int alpha = index < nindexesWithAlpha ? trns.GetPalletteAlpha () [ index ] : 255;
             buf [ c * channels + 3 ] = alpha;
         }
     }
     return buf;
 }
예제 #7
0
 public static int[] Palette2rgb( ImageLine line, PngChunkPLTE pal, int [] buf )
 {
     return Palette2rgb ( line, pal, null, buf );
 }
예제 #8
0
 public PngChunkPLTE CreatePLTEChunk()
 {
     PngChunkPLTE plte = new PngChunkPLTE(chunkList.imageInfo);
     QueueChunk(plte);
     return plte;
 }