How to crop an image using C#?

后端 未结 14 1076
忘掉有多难
忘掉有多难 2020-11-22 05:16

How can I write an application that will crop images in C#?

14条回答
  •  南旧
    南旧 (楼主)
    2020-11-22 05:49

    It's quite easy:

    • Create a new Bitmap object with the cropped size.
    • Use Graphics.FromImage to create a Graphics object for the new bitmap.
    • Use the DrawImage method to draw the image onto the bitmap with a negative X and Y coordinate.

提交回复
热议问题