C# 바이트 스트림을 그림으로 변환하는 실례 방법

1885 단어
 
  
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Drawing;
usingSystem.IO;
namespaceMicrosoft.Form.Base
{
    classImageToByte
    {
        ///
        ///
        ///

        /// Image
        ///
        publicstaticbyte[] ImgToByt(Image img)
        {
            MemoryStream ms = newMemoryStream();
            byte[] imagedata = null;
            img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            imagedata = ms.GetBuffer();
            returnimagedata;            
        }
        ///
        ///
        ///

        ///
        /// Image
        publicstaticImage BytToImg(byte[] byt)
        {
            MemoryStream ms = newMemoryStream(byt);
            Image img = Image.FromStream(ms);
            returnimg;
        }
        //
        ///
        /// byte[]
        ///

        ///
        ///
        privatestaticbyte[] getImageByte(stringimagePath)
        {
            FileStream files = newFileStream(imagePath, FileMode.Open);
            byte[] imgByte = newbyte[files.Length];
            files.Read(imgByte, 0, imgByte.Length);
            files.Close();
            returnimgByte;
        }
    }
}

좋은 웹페이지 즐겨찾기