944,201 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 9741
  • VB.NET RSS
Jun 14th, 2007
0

picture box in vb.net 2003.

Expand Post »
hi i am using vb.net 2003 ,i have got a problem ,i have a 'tif' image .i am showing it in picture box ,now i want to cut some portion of this image and save in another location .so how can i do it.Pls help
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
guptaalok12 is offline Offline
25 posts
since Jun 2007
Jun 14th, 2007
0

Re: picture box in vb.net 2003.

moved
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,963 posts
since Aug 2005
Jun 14th, 2007
0

Re: picture box in vb.net 2003.

What you want to do is crop a particular image and save it in different location?
Reputation Points: 347
Solved Threads: 13
Practically a Posting Shark
arjunsasidharan is offline Offline
812 posts
since Aug 2006
Jun 15th, 2007
0

Re: picture box in vb.net 2003.

Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005
Jun 16th, 2007
1

Re: picture box in vb.net 2003.

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
Reputation Points: 84
Solved Threads: 58
Posting Pro in Training
waynespangler is offline Offline
461 posts
since Dec 2002

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: how to convert C++ DLL to be compatible with C#
Next Thread in VB.NET Forum Timeline: Using Crystal reports in Winforms in Vb.net





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC