• 从流获取缩略图


     /// <summary>
            /// 从流获取缩略图
            /// </summary>
            /// <param name="filePathWithFileName"></param>
            private void CreateFavoriteThumb(string filePathWithFileName)
            {
                if (Request.InputStream == null || Request.InputStream.Length == 0)
                {
                    throw new Exception("没有接收到缩略图文件流");
                }

                MemoryStream ms = null;
                try
                {
                    using (ms = new MemoryStream())
                    {
                        byte[] buffer = new byte[Request.InputStream.Length];
                        int read;
                        while ((read = Request.InputStream.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            ms.Write(buffer, 0, read);
                        }
                        Bitmap b = new Bitmap(ms);
                        b.Save(filePathWithFileName);
                    }
                }
                catch
                {
                    throw new Exception("缩略图保存失败");
                }
                finally
                {
                    if (ms != null)
                    {
                        ms.Flush();
                        ms.Close();
                        ms = null;
                    }
                }
            }

  • 相关阅读:
    openlayers 学习笔记之1
    objective C 学习之02
    xcode 中 的工程模板
    xcode 创建项目 勾选 git 出现警告
    html+css复习之第3篇 | jquery | bootstrap
    html+css复习之第2篇 | javascript
    iOS开发系列之 itms-services 协议
    App store 如何使用 promo code | app store 打不开精品推荐和排行榜
    设计一组N个数,确定其中第k个最大值
    [搬运]如何在C++中实现多态性
  • 原文地址:https://www.cnblogs.com/zhtbk/p/4530745.html
Copyright © 2020-2023  润新知