zoukankan      html  css  js  c++  java
  • 图片转换成Byte[]

             在我之前用的代码是这样的。。结果图片一大 就内存不够用。。 
    
    Bitmap image = new Bitmap(fileName); MemoryStream stream = new MemoryStream(); image.Save(stream, System.Drawing.Imaging.ImageFormat.Png); return stream.ToArray();
              
         应该把代码改成这样。然后在把  Web.config maxRequestLength="196000"
        改小一点

      FileStream sFile = new FileStream(fileName, FileMode.Open);             //获取文件长度              int nFileLength = (int) sFile.Seek(0, SeekOrigin.End);             //修正偏移              sFile.Seek(0, SeekOrigin.Begin);             //申请空间              byte[] btFile = new byte[nFileLength];             //读文件              sFile.Read(btFile, 0, nFileLength);             sFile.Close();             return btFile;

    这样就可以上传20MB左右的图片了。。
  • 相关阅读:
    线程池和进程池
    初识数据库
    线程q
    event事件
    死锁和递归锁
    信号量
    PythonStudy——线程中的几种消息队列
    PythonStudy——GIL Global Interpreter Lock 全局解释器锁
    PythonStudy——异步回调
    PythonStudy——日志模块 logging
  • 原文地址:https://www.cnblogs.com/w2011/p/3110037.html
Copyright © 2011-2022 走看看