tags:

views:

34

answers:

1

since i do not have any image editing software, i am going to use vb.net to slice an image horizontally. can someone help me get started please?

+1  A: 

In the code below you first load the image, then create a new image with the new width and height, grab the Graphics object from it and finally draw the old image onto the new image. We draw the old image onto the new image using the old image's dimensions but since the new image is smaller the rest will be off of the canvas.

    Private Shared Sub CropImage(ByVal inputImagePath As String, ByVal outputImagePath As String, ByVal newHeight As Integer)
    Using oldImage = System.Drawing.Image.FromFile(inputImagePath)
        Using NewImage As New System.Drawing.Bitmap(oldImage.Width, newHeight)
            Using G = Graphics.FromImage(NewImage)
                G.DrawImage(oldImage, 0, 0, oldImage.Width, oldImage.Height)
                NewImage.Save(outputImagePath, System.Drawing.Imaging.ImageFormat.Jpeg)
            End Using
        End Using
    End Using
End Sub
Chris Haas