zoukankan      html  css  js  c++  java
  • 图片二进制转换

    图片转化为二进制
    
    using (FileStream fs = new FileStream(picpath, FileMode.Open, FileAccess.Read))
                        //        {
                        //            using (BinaryReader read = new BinaryReader(fs))
                        //            {
                        //                photobyte = read.ReadBytes((int)fs.Length);
                        //                s1 = photobyte.Length;
                        //            }
                        //        }
    
     
    
     
    
    二进制转化为图片
    
     string sa = dsimg.Tables[0].Rows[0]["image"].ToString();
                            System.Text.Encoding enc = System.Text.Encoding.UTF8;
                            photobyte = enc.GetBytes(sa);
                            Image image1 = BytesToImage(photobyte);
                            image1.Save(@"D:淘宝图片" + outer_idaaa + ".JPG", System.Drawing.Imaging.ImageFormat.Jpeg);
    
     
    
     
    
     
    
    二进制转化为图片保存
    
     class Program
        {
            public static Image BytesToImage(byte[] bytes)
            {
               MemoryStream ms = new MemoryStream(bytes);
                Image image = new Bitmap(ms, true);
               return image;
            }
    
            public static void Main(string[] args)
            {
                byte[] photobyte;
                int s1;
                using (FileStream fs = new FileStream(@"D:淘宝图片1752967.jpg", FileMode.Open, FileAccess.Read))
                {
                    using (BinaryReader read = new BinaryReader(fs))
                    {
                        photobyte = read.ReadBytes((int)fs.Length);
                        s1 = photobyte.Length;
                        Image image1 = BytesToImage(photobyte);
                       image1.Save(@"E:1.JPG", System.Drawing.Imaging.ImageFormat.Jpeg);
                //    }
                //}
    
        }
    
    }
  • 相关阅读:
    第十八周作业
    第十七周作业
    第十六周作业
    第十五周作业
    第十四周作业
    第十三周作业
    第十二周作业
    第二阶段考试
    第十周作业
    启航,带着梦想出发!
  • 原文地址:https://www.cnblogs.com/happygx/p/3424781.html
Copyright © 2011-2022 走看看