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);

    }

  • 相关阅读:
    第四次作业
    软工第三次作业
    第三次作业
    第二次作业
    团队第三次作业:Alpha版本发布
    软件工程团队作业--Alpha版本第二周小结
    软件工程团队作业--Alpha版本第一周小结
    团队第二次作业
    C++多态性总结
    第四次作业:结对编程
  • 原文地址:https://www.cnblogs.com/attilax/p/15199872.html
Copyright © 2011-2022 走看看