by
0
7
323k
2
Top 1% !
Popular
Pearl of Wisdom
Easy-to-find
Specified
Tuned
OpenSource
Popularity: 3177th place
Created
Modified Nov 13, 2015
.NETFramework4.5
Architecturex86_64
Extension.cs
InputName0source
InputName1section
InputType0Bitmap
InputType1Rectangle
LanguageCSharp
MethodNameCropImage
OutputTypeBitmap

Crop Image on C#

Simple snippet to Crop Image from up-left point
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/778222/Crop-Image-on-C-?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
public static Bitmap CropImage(this Bitmap source, Rectangle section) { Bitmap bmp = new Bitmap(section.Width, section.Height); Graphics g = Graphics.FromImage(bmp); g.DrawImage(source, 0, 0, section, GraphicsUnit.Pixel); return bmp; }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus