圖片

来源:互联网 发布:网络环境下的信息系统 编辑:程序博客网 时间:2024/04/19 19:17


 

public static class BitmapHelper    {        public static Bitmap BytesToBitmap(byte[] Bytes)        {            MemoryStream stream = null;            try            {                stream = new MemoryStream(Bytes);                return new Bitmap((Image)new Bitmap(stream));            }            catch (ArgumentNullException ex)            {                throw ex;            }            catch (ArgumentException ex)            {                throw ex;            }            finally            {                stream.Close();            }        }         public static byte[] BitmapToBytes(Bitmap Bitmap)        {            MemoryStream ms = null;            try            {                ms = new MemoryStream();                Bitmap.Save(ms, Bitmap.RawFormat);                byte[] byteImage = new Byte[ms.Length];                byteImage = ms.ToArray();                return byteImage;            }            catch (ArgumentNullException ex)            {                throw ex;            }            finally            {                ms.Close();            }        }    }


 


原创粉丝点击