Image and BYTE array conversion [Reference]

xiaoxiao2021-03-06  42

Image to byte []

MemoryStream MS = New MemoryStream ();

IMAGEDATA = NULL;

Picturebox1.image.save (ms, system.drawing.image.imageformat.gif);

Imagedata = ms.getBuffer ();

Byte [] to image

System.drawing.Image img;

MemoryStream MS = New MemoryStream ();

MS = new system.io.MemoryStream ((byte []) content);

IMG = system.drawing.image.fromstream (ms);

IF (img.width> convert.toint32 (_width))

{

_WIDTH = 500;

_Height = (img.height * control.toint32 (_width) / img.width;

}

Else

{

_WIDTH = img.width;

_height = img.height;

}

img.dispose ();

转载请注明原文地址:https://www.9cbs.com/read-55673.html

New Post(0)