publicstaticclassBitmapHelper
{
//二進位制轉換為圖
publicstaticBitmapBytesToBitmap(byte[]Bytes)
MemoryStreamstream=null;
try
stream=newMemoryStream(Bytes);
returnnewBitmap((Image)newBitmap(stream));
}
catch(ArgumentNullExceptionex)
throwex;
catch(ArgumentExceptionex)
finally
stream.Close();
//圖轉換為二進位制
publicstaticbyte[]BitmapToBytes(BitmapBitmap)
MemoryStreamms=null;
ms=newMemoryStream();
Bitmap.Save(ms,Bitmap.RawFormat);
byte[]byteImage=newByte[ms.Length];
byteImage=ms.ToArray();
returnbyteImage;
ms.Close();
publicstaticclassBitmapHelper
{
//二進位制轉換為圖
publicstaticBitmapBytesToBitmap(byte[]Bytes)
{
MemoryStreamstream=null;
try
{
stream=newMemoryStream(Bytes);
returnnewBitmap((Image)newBitmap(stream));
}
catch(ArgumentNullExceptionex)
{
throwex;
}
catch(ArgumentExceptionex)
{
throwex;
}
finally
{
stream.Close();
}
}
//圖轉換為二進位制
publicstaticbyte[]BitmapToBytes(BitmapBitmap)
{
MemoryStreamms=null;
try
{
ms=newMemoryStream();
Bitmap.Save(ms,Bitmap.RawFormat);
byte[]byteImage=newByte[ms.Length];
byteImage=ms.ToArray();
returnbyteImage;
}
catch(ArgumentNullExceptionex)
{
throwex;
}
finally
{
ms.Close();
}
}
}