Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crop an image

Status
Not open for further replies.

oka97

Programmer
May 25, 2003
28
0
0
GB
Hey people, I'm pulling my hair out, I can't figure out how to crop an image to a simple retangle size.

I've got an image, set it to a graphics object and set a retangle to that, but can't see what to do after :(
 
Thanks for all the help people! This is a great vb.net forum.

--

Private Function Crop(ByVal Source As Bitmap, ByVal x As Int32, ByVal y As Int32, ByVal width As Int32, ByVal height As Int32) As Bitmap
Dim Cropped As New Bitmap(width, height)
Dim g As Graphics = Graphics.FromImage(Cropped)
g.CompositingQuality = Drawing2D.CompositingQuality.HighQuality
g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
Dim rect As New Rectangle(0, 0, width, height)
g.DrawImage(Source, rect, x, y, width, height, GraphicsUnit.Pixel)
Return Cropped
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top