C# 图片截取
#region 原图大小
Bitmap sourceBitmap = new Bitmap(picBox.Width, picBox.Height);
panelImage.DrawToBitmap(sourceBitmap, new Rectangle(0, 0, picBox.Width, picBox.Height));
#endregion
#region 区域截取
Image imageSource = sourceBitmap;或者( Image.FromFile(filepath))
double orgWidth = IntDouble(imageSource.Width);
double orgHight = IntDouble(imageSource.Height);
Rectangle cropArea = new Rectangle();
double x = orgWidth / 2 - 145;(145是从中间开始向两边截图的宽度,可以自定义)
double y = 0;
double width = 290;
double height = orgHight;
cropArea.X = DoubleInt(x);
cropArea.Y = DoubleInt(y);
cropArea.Width = DoubleInt(width);
cropArea.Height = DoubleInt(height);
Bitmap bmpImage = new Bitmap(imageSource);
Bitmap bmpCrop = bmpImage.Clone(cropArea, bmpImage.PixelFormat);
newPicBox.Imae=bmpCrop;
#endregion