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

    }

  • 相关阅读:
    [APIO2017]商旅(分数规划,spfa)
    Codeforces Round #542 div1
    Codeforces Round #556 (Div. 2)
    Codeforces Round #543
    Codeforces Round #534 (Div. 1)
    公式的复习?
    关于概率dp的HINT
    [JSOI2009]密码 [AC自动机]
    bzoj1444[Jsoi2009]有趣的游戏[AC自动机]
    「LibreOJ β Round #4」框架 [bitset]
  • 原文地址:https://www.cnblogs.com/attilax/p/15199872.html
Copyright © 2011-2022 走看看