zoukankan      html  css  js  c++  java
  • 数据库上传图片及裁剪图片

    INSERT tb(photo)
        SELECT img FROM OPENROWSET(BULK 'c:me.jpg',SINGLE_BLOB) AS T(img);
     
    裁剪图片
     1  /// <summary>
     2         /// 压缩图片并居中裁剪
     3         /// </summary>
     4         /// <param name="imageSource">源图片</param>
     5         /// <param name="dHeight">裁剪到高度</param>
     6         /// <param name="dWidth">裁剪到宽度</param>
     7         /// <returns></returns>
     8         public byte[] CropPic(System.Drawing.Image imageSource, int dHeight, int dWidth)
     9         {
    10             ImageFormat tFormat = imageSource.RawFormat;
    11             Bitmap oB = new Bitmap(dWidth, dHeight);
    12             Graphics g = Graphics.FromImage(oB);
    13             g.Clear(Color.WhiteSmoke);
    14             g.CompositingQuality = CompositingQuality.HighQuality;
    15             g.SmoothingMode = SmoothingMode.HighQuality;
    16             g.InterpolationMode = InterpolationMode.HighQualityBicubic;
    17             g.DrawImage(imageSource, new Rectangle(0, 0, dWidth, dHeight), (imageSource.Width - dWidth * imageSource.Height / dHeight) / 2, 0, dWidth * imageSource.Height / dHeight, imageSource.Height, GraphicsUnit.Pixel);
    18             MemoryStream stream = new MemoryStream();
    19             oB.Save(stream, ImageFormat.Jpeg);
    20             return stream.ToArray();
    21         }
    View Code
     

  • 相关阅读:
    LeetCode 029 Divide Two Integers
    LeetCode 028 Implement strStr()
    Linux网络技术管理及进程管理
    RAID磁盘阵列及CentOS7系统启动流程
    Linux磁盘管理及LVM讲解(1)
    逻辑卷管理
    Linux磁盘管理及LVM讲解
    Linux计划任务及压缩归档
    Linux权限管理
    用户及用户组管理
  • 原文地址:https://www.cnblogs.com/softxu/p/3171181.html
Copyright © 2011-2022 走看看