using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace cutimg
{
    class Program
    {
        static void Main(string[] args)
        {
            Bitmap b = file2img(@args[4]);
            Bitmap bb = img_tailor(b, new Rectangle(Int32.Parse(args[0]), Int32.Parse(args[1]), Int32.Parse(args[2]), Int32.Parse(args[3])));
            img2file(bb, @args[5]);
        }
        public static Bitmap img_tailor(Bitmap src, Rectangle range)
        {
            return src.Clone(range, System.Drawing.Imaging.PixelFormat.DontCare);
        }
        //图片读取
        public static Bitmap file2img(string filepath)
        {
            Bitmap b = new Bitmap(filepath);
            return b;
        }
        //图片生成
        public static void img2file(Bitmap b, string filepath)
        {
            b.Save(filepath);
        }


    }
}

一共引用6个args[],其中前面四个是:x坐标,Y坐标,宽,高,后面两个是原图片和保存到的图片路径。
使用ImageGlass打开后裁剪时可以得到这些参数。
显示的参数结果

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐