• c# 将byte数组保存成图片


    将byte数组保存成图片:

    方式一:System.IO.File.WriteAllBytes(@"c: est.jpg", bytes);

    方式二:MemoryStream ms=new MemoryStream(Byte[] b);  把那个byte[]数组传进去,然后
               FileStream fs=new FileStream(路径 例如:"E:image1.jpg");
        ms.writeto(fs);
        ms.close();
        fs.close();

    方法三:

           //得到图片地址
           var stringFilePath = context.Server.MapPath(string.Format("~/Image/{0}{1}.jpg", imageName, id));
           //声明一个FileStream用来将图片暂时放入流中
           FileStream stream = new FileStream(stringFilePath, FileMode.Open);
           using (stream)
           {
               //透过GetImageFromStream方法将图片放入byte数组中
               byte[] imageBytes = this.GetImageFromStream(stream,context);
               //上下文确定写到客户短时的文件类型
               context.Response.ContentType = "image/jpeg";
               //上下文将imageBytes中的数据写到前段
               context.Response.BinaryWrite(imageBytes);
               stream.Close();
            }
  • 相关阅读:
    pycharm运行html文件报404错误
    css3 鼠标悬浮动画效果
    子代选择器和后代选择器的区别
    前端入门
    爬虫Scrapy框架
    BeautifulSoup
    爬虫之selenium使用
    爬虫之BeautifulSoup
    urllib模块
    爬虫基础
  • 原文地址:https://www.cnblogs.com/zz-930474270/p/6046033.html
Copyright © 2020-2023  润新知