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


What you want to do is crop a particular image and save it in different location?

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
commented: good alternative +10
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.