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


usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Drawing;
usingSystem.IO;
namespaceMicrosoft.Form.Base
{
    classImageToByte
    {
        /// <summary>
        ///
        /// </summary>
        /// <param name="img"> Image </param>
        /// <returns> </returns>
        publicstaticbyte[] ImgToByt(Image img)
        {
            MemoryStream ms = newMemoryStream();
            byte[] imagedata = null;
            img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            imagedata = ms.GetBuffer();
            returnimagedata;            
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="byt"> </param>
        /// <returns> Image </returns>
        publicstaticImage BytToImg(byte[] byt)
        {
            MemoryStream ms = newMemoryStream(byt);
            Image img = Image.FromStream(ms);
            returnimg;
        }
        //
        /// <summary>
        /// byte[]
        /// </summary>
        /// <param name="imagePath"> </param>
        /// <returns> </returns>
        privatestaticbyte[] getImageByte(stringimagePath)
        {
            FileStream files = newFileStream(imagePath, FileMode.Open);
            byte[] imgByte = newbyte[files.Length];
            files.Read(imgByte, 0, imgByte.Length);
            files.Close();
            returnimgByte;
        }
    }
}

좋은 웹페이지 즐겨찾기