ZForge.Controls.TreeViewAdv.GifDecoder.SetPixels C# (CSharp) Method

SetPixels() private method

private SetPixels ( ) : void
return void
        private void SetPixels()
        {
            // expose destination image's pixels as int array
            //		int[] dest =
            //			(( int ) image.getRaster().getDataBuffer()).getData();
            int[] dest = GetPixels( bitmap );

            // fill in starting image contents based on last image's dispose code
            if (lastDispose > 0)
            {
                if (lastDispose == 3)
                {
                    // use image before last
                    int n = frameCount - 2;
                    if (n > 0)
                    {
                        lastImage = GetFrame(n - 1).Image;
                    }
                    else
                    {
                        lastImage = null;
                    }
                }

                if (lastImage != null)
                {
                    //				int[] prev =
                    //					((DataBufferInt) lastImage.getRaster().getDataBuffer()).getData();
                    int[] prev = GetPixels( new Bitmap( lastImage ) );
                    Array.Copy(prev, 0, dest, 0, width * height);
                    // copy pixels

                    if (lastDispose == 2)
                    {
                        // fill last image rect area with background color
                        Graphics g = Graphics.FromImage( image );
                        Color c = Color.Empty;
                        if (transparency)
                        {
                            c = Color.FromArgb( 0, 0, 0, 0 ); 	// assume background is transparent
                        }
                        else
                        {
                            c = Color.FromArgb( lastBgColor ) ;
                            //						c = new Color(lastBgColor); // use given background color
                        }
                        Brush brush = new SolidBrush( c );
                        g.FillRectangle( brush, lastRect );
                        brush.Dispose();
                        g.Dispose();
                    }
                }
            }

            // copy each source line to the appropriate place in the destination
            int pass = 1;
            int inc = 8;
            int iline = 0;
            for (int i = 0; i < ih; i++)
            {
                int line = i;
                if (interlace)
                {
                    if (iline >= ih)
                    {
                        pass++;
                        switch (pass)
                        {
                            case 2 :
                                iline = 4;
                                break;
                            case 3 :
                                iline = 2;
                                inc = 4;
                                break;
                            case 4 :
                                iline = 1;
                                inc = 2;
                                break;
                        }
                    }
                    line = iline;
                    iline += inc;
                }
                line += iy;
                if (line < height)
                {
                    int k = line * width;
                    int dx = k + ix; // start of line in dest
                    int dlim = dx + iw; // end of dest line
                    if ((k + width) < dlim)
                    {
                        dlim = k + width; // past dest edge
                    }
                    int sx = i * iw; // start of line in source
                    while (dx < dlim)
                    {
                        // map color and insert in destination
                        int index = ((int) pixels[sx++]) & 0xff;
                        int c = act[index];
                        if (c != 0)
                        {
                            dest[dx] = c;
                        }
                        dx++;
                    }
                }
            }
            SetPixels( dest );
        }

Same methods

GifDecoder::SetPixels ( int pixels ) : void