| | |
picture box in vb.net 2003.
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2002
Posts: 461
Reputation:
Solved Threads: 56
Try this and see if it is what you want.
Private Sub btnCropImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCropImage.Click
If PictureBox1.Image Is Nothing Then Exit Sub
'-----------------------------------------------------------
' The size is how wide and tall the cropped protion is
' The Point is x,y of where your cropped portion starts
' Call the CropImage as below
'------------------------------------------------------------ PictureBox2.Image = CropImage(PictureBox1.Image, New Size(100, 100), New Point(100, 100)).Clone
End Sub
Private Function CropImage(ByVal SrcBmp As Bitmap, ByVal NewSize As Size, ByVal StartPoint As Point) As Bitmap
' Set up the rectangle that shows the portion of image to be cropped
Dim SrcRect As New Rectangle(StartPoint.X, StartPoint.Y, NewSize.Width, NewSize.Height)
' Now set up the destination rectangle(DestRect) and bitmap(DestBmp)
Dim DestRect As New Rectangle(0, 0, NewSize.Width, NewSize.Height)
Dim DestBmp As New Bitmap(NewSize.Width, NewSize.Height, Imaging.PixelFormat.Format32bppArgb)
' Set the graphics to the destination bitmap(DestBmp)
Dim g As Graphics = Graphics.FromImage(DestBmp)
' and draw the image from source bitmap (SrcRect) to the
' destination bitmap(DestBmp) using the destination and
' source rectangles.
g.DrawImage(SrcBmp, DestRect, SrcRect, GraphicsUnit.Pixel)
' finally return the destBmp
Return DestBmp
End Function![]() |
Similar Threads
- Visual Studio 6.0 or Visual Studio .Net 2003? (Windows Software)
- Visual Studio 6.0 or Visual Studio .Net 2003 (C++)
- how to update visual studio .net 2003 (ASP.NET)
- how to run .net 2003 trial version on Terminal server 2000 (VB.NET)
Other Threads in the VB.NET Forum
- Previous Thread: how to convert C++ DLL to be compatible with C#
- Next Thread: Using Crystal reports in Winforms in Vb.net
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account arithmetic array basic beginner bing browser button buttons center check code crystalreport cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic dropdownlist excel fade file-dialog filter forms ftp generatetags google hardcopy html images input insert intel internet mobile monitor net networking objects open output panel passingparameters pdf picturebox picturebox1 port position print printing problem project save searchbox searchvb.net select serial settings shutdown soap sqlserver survey table tcp temperature text textbox timer timespan toolbox transparency trim update user vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vba vbnet visual visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode year






