Far*_*man 3 .net c# image-manipulation winforms
我想剪切图片的特定部分,并用它来比较裁剪后的图像与HDD中存储的图像.问题是我不知道如何获得源图像的特定部分.我知道要裁剪的图像的位置(X,Y).
Ed *_* S. 18
这将加载原件并创建一个从(0,0)开始并且尺寸为64x64的裁剪版本.
Bitmap original = new Bitmap( @"C:\SomePath" );
Rectangle srcRect = new Rectangle( 0, 0, 64, 64 );
Bitmap cropped = (Bitmap)original.Clone( srcRect, original.PixelFormat );
Run Code Online (Sandbox Code Playgroud)
顺便说一下,你没有指定这是WinForms还是WPF,所以使用WinForms,因为我真的不知道WPF图像处理功能.