Ejemplo n.º 1
0
        public static Bitmap ToBitmap(this PixelData pixelData)
        {
            if (pixelData.Width == 0 || pixelData.Height == 0)
            {
                return(new Bitmap(1, 1));
            }

            int[]      argbValues = pixelData.GetPixelDataIntArgb();
            Bitmap     bm         = new Bitmap(pixelData.Width, pixelData.Height);
            BitmapData data       = bm.LockBits(
                new Rectangle(0, 0, bm.Width, bm.Height),
                ImageLockMode.WriteOnly,
                PixelFormat.Format32bppArgb);

            int pixels = data.Width * data.Height;

            Marshal.Copy(argbValues, 0, data.Scan0, pixels);

            bm.UnlockBits(data);
            return(bm);
        }