zoukankan      html  css  js  c++  java
  • paip.c#图片裁剪

    paip.c#图片裁剪

       pictureBox1.Image=PTImage.CutForCustomx(@"d:\img.jpg",100,300);
                pictureBox1.Image.Save(@"d:\img2.jpg");

            public static Image CutForCustomx(string imgPath, int top,int height)
            {


                FileStream fs = new FileStream(imgPath, FileMode.Open, FileAccess.Read);
                //从文件获取原始图片,并使用流中嵌入的颜色管理信息
                System.Drawing.Image initImage = System.Drawing.Image.FromStream(fs, true);

                Bitmap b = new Bitmap(initImage);

                Bitmap img = b.Clone(new Rectangle(0, top, initImage.Width, height), System.Drawing.Imaging.PixelFormat.DontCare);
                return (Image)(img);


            }

    public static Image CutForCustomx(string imgPath, Rectangle rec)
    {

    FileStream fs = new FileStream(imgPath, FileMode.Open, FileAccess.Read);
    //从文件获取原始图片,并使用流中嵌入的颜色管理信息
    System.Drawing.Image initImage = System.Drawing.Image.FromStream(fs, true);

    Bitmap b = new Bitmap(initImage);

    Bitmap img = b.Clone(rec, System.Drawing.Imaging.PixelFormat.DontCare);
    return (Image)(img);

    }

  • 相关阅读:
    496. 下一个更大元素 I 力扣(简单) 单调栈
    240. 搜索二维矩阵 II 力扣(中等) Z字型查找
    638. 大礼包 力扣(中等) 记忆化搜索,弱点
    453. 最小操作次数使数组元素相等 力扣(简单) 没想出来
    传纸条
    同余方程
    花匠
    华容道
    货车运输
    火柴排队
  • 原文地址:https://www.cnblogs.com/attilax/p/15199872.html
Copyright © 2011-2022 走看看