#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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2021-11-05
  • 2021-06-07
  • 2021-09-01
猜你喜欢
  • 2022-12-23
  • 2021-12-24
  • 2018-12-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案