zoukankan      html  css  js  c++  java
  • CutandZoom 图片剪切类

    public class CutandZoom
      {
          /// <summary>
          /// 剪切图片
          /// </summary>
          /// <param name="path_source">原始图片路径</param>
          /// <param name="path_save">目标图片路径</param>
          /// <param name="x">剪切位置的左上角x坐标</param>
          /// <param name="y">剪切位置的左上角y坐标</param>
          /// <param name="width">要剪切的宽度</param>
          /// <param name="height">要剪切的高度</param>
          public void Cut(string path_source, string path_save, int x, int y, int width, int height, int intWidth, int intHeight)
          {
              //加载底图
              Image img = Image.FromFile(path_source);
              int w = img.Width;
              int h = img.Height;
              //设置画布
              width = width >= w ? w : width;
              height = height >= h ? h : height;
              Bitmap map = new Bitmap(width, height);
              //绘图
              Graphics g = Graphics.FromImage(map);
              //设置图片质量
              //g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
              //g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
    
              g.DrawImage(img, 0, 0, new Rectangle(x, y, width, height), GraphicsUnit.Pixel);
              //保存
              System.Drawing.Bitmap objNewPic = new System.Drawing.Bitmap(map, intWidth, intHeight);
              // map.Save(path_save);
              objNewPic.Save(path_save);
    
          }
    
      }
  • 相关阅读:
    poj 1679 Prim判断次短路
    poj 3621 二分+spfa
    poj 3613 floyd + 快速幂
    poj3463 最短路和比最短路长1的路径数
    poj 3635 带花费的Dij+head优化
    poj 3013 SPFA
    POJ 2449 Dijstra + A* K短路
    webStorm关于ESlint6语法格式化解决方案
    Vue之 css3 样式重置 代码
    vue常用组件
  • 原文地址:https://www.cnblogs.com/osmeteor/p/3369983.html
Copyright © 2011-2022 走看看