Example #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);
        }
Example #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);
        }
Example #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);
        }