Translate image objects and Byte []

xiaoxiao2021-03-06  47

/ / Need to introduce the namestem; use system.io; useing system.drawing; using system.runtime.serialization.formatters.binary; // Introduction to the sequential IMAGE object Using // The following is the conversion method // 将 image is converted to byte [] public byte [] ConvertImage (Image image) {FileStream fs = new FileStream ( "imagetemp", FileMode.Create, FileAccess.Write, FileShare.None); BinaryFormatter bf = new BinaryFormatter (); bf.Serialize ( FS, (Object); fs.close (); fs = new filestream ("imageteemp", filemode.open, fileaccess.read, fileshare.none); byte [] bytes = new byte [fs.length]; fs .Read (bytes, 0, (int) fs.length); fs.close (); returnity ()} // convert Byte [] to ImagePublic Image Readimage (Byte [] Bytes) {filestream fs = new filestream (" ImageTemp1 ", FileMode.create, FileAccess.write, Fileshare.none;" fs.writeby ";} fs.close ();} fs.close (); fs = new filestream (" iMageTemp1 ", FileMode.Open FileAccess.read, fileshare.none; binaryformatter bf = new binaryformatter (); object obj = bf.deserialize (fs); fs.close (); return (IMA GE) Obj;} Finally, finally, 5555, finally can sleep! ! / Take over this morning, make the first revision, as follows: ///

/// 将Te [] converted to image /// /// byte array /// Image public image readimage (byte [] Bytes) {MemoryStream ms = new memoryStream (bytes, 0, bytes.length); binaryformatter bf = New binaryformatter (); object obj = bf.deSerialize (ms); ms.close (); return (image) Obj;} /// /// converts image to Byte [] /// /// image /// byte []

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

New Post(0)