MSIT.NGif.GifEncoder.GetImagePixels C# (CSharp) Method

GetImagePixels() private method

private GetImagePixels ( ) : void
return void
        private unsafe void GetImagePixels()
        {
            int w = _image.Width;
            int h = _image.Height;
            if ((w != _width) || (h != _height)) {
                Image temp = new Bitmap(_width, _height);
                Graphics g = Graphics.FromImage(temp);
                g.DrawImage(_image, 0, 0);
                _image = temp;
                g.Dispose();
            }
            w = _width;
            h = _height;

            Bitmap tempBitmap = new Bitmap(_image);
            BitmapData bd = tempBitmap.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
            byte* p = (byte*)bd.Scan0;
            _pixels = new Byte[3 * w * h];
            int stridePad = bd.Stride - (3*w);
            fixed (byte* v = _pixels) {
                byte* q = v;
                for (int y = 0; y < h; y++, p += stridePad) {
                    for (int x = 0; x < w; x++, q += 3) {
                        *(q+2) = *(p++);
                        *(q+1) = *(p++);
                        *q = *(p++);
                    }
                }
            }
            tempBitmap.UnlockBits(bd);
            tempBitmap.Dispose();
        }