Total Pageviews

Showing posts with label PictureBox. Show all posts
Showing posts with label PictureBox. Show all posts

Sunday, October 23, 2016

Resize Images In VB.NET

This code can be used to resize images in Visual Basic 2015 too.

Try
    SaveFileDialog1.Filter = "JPEG|*.jpg"
    If SaveFileDialog1.ShowDialog = DialogResult.OK Then
        Using bm As New Bitmap(PictureBox1.Image, 1024, 500)
            bm.Save(SaveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg)
            bm.Save(PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage)
        End Using
        MsgBox("Your File Created")
     End If
 Catch ex As Exception
End Try


1024, 500 cab be intered trough textboxes too

Try
    SaveFileDialog1.Filter = "JPEG|*.jpg"
    If SaveFileDialog1.ShowDialog = DialogResult.OK Then
        Using bm As New Bitmap(PictureBox1.Image, txtbox1.Text,
txtbox2.Text,)
            bm.Save(SaveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg)
            bm.Save(PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage)
        End Using
        MsgBox("Your File Created")
     End If
 Catch ex As Exception
End Try