zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    qsort
    strcmp
    LotteryDrawing
    retire or not retire ? is a question.
    alloc && afree
    strlen
    c point
    c point ccccc
    MySQL MGR源码分析2
    MySQL MGR实现分析
  • 原文地址:https://www.cnblogs.com/ybb521/p/3369738.html
Copyright © 2011-2022 走看看