Exemplo n.º 1
0
        public static Bitmap UpdateFromByteArray_Color(this Image im, byte[] data)
        {
            //Bitmap bmp = new Bitmap(width, height, PixelFormat.Format32bppRgb);

            LockBitmap lockBitmap = new LockBitmap((Bitmap)im);

            lockBitmap.LockBits();
            lockBitmap.Pixels = data;


            lockBitmap.UnlockBits();

            return((Bitmap)im);
        }
Exemplo n.º 2
0
        public static Bitmap FromByteArray_Gray(byte[] data, int width, int height)
        {
            System.Drawing.Bitmap bitmap8bpp = new Bitmap(width, height, PixelFormat.Format8bppIndexed);

            bitmap8bpp.Palette = ImageExtensions.GrayScalePalette;


            LockBitmap lockBitmap = new LockBitmap(bitmap8bpp);

            lockBitmap.LockBits();
            lockBitmap.Pixels = data;

            lockBitmap.UnlockBits();


            return(bitmap8bpp);
        }
Exemplo n.º 3
0
        public static Bitmap Update_Color(this Bitmap bm, byte[] data)
        {
            try
            {
                LockBitmap lockBitmap = new LockBitmap(bm);
                lockBitmap.LockBits();
                lockBitmap.Pixels = data;

                lockBitmap.UnlockBits();

                return(bm);
            }
            catch (Exception err)
            {
                System.Windows.Forms.MessageBox.Show("Error in updating bitmap : " + err.Message);
            }
            return(null);
        }