How To Change The Format Of A Picture…

 

  First Load the picture into a PictureBox….

  PictureBox1.Image = Image.FromFile(SourceFile)

 

  Dim Format As Imaging.ImageFormat

 

 '  In the following line, You can Change The Format.GIf

 '  Into Format.Bmp or Format.Jpg or Format.Png or Whatever You want.

  PictureBox1.Image.Save(DestinationFile, Format.Gif)

 

 

 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 

        'Notice the image does NOT have to be a Bitmap....In this case, it's a jpg   

        Dim MyImage = New Bitmap("c:\junk.jpg")

        '*************************************************************************

 

        ' Stretches the image to fit the pictureBox.

        PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

 

        'MyImage.Size.ToString will look something like this: {Width=800,Height=600} -- The width starts in the 8th

        'position and the height starts in the 9th position after the comma.

        Dim a As Array = Split(MyImage.Size.ToString, ",")

        Dim Width As Double = Val(Mid(a(0), 8, 100))

        Dim Height As Double = Val(Mid(a(1), 9, 100))

        '***********************************************************************************************************

 

        PictureBox1.ClientSize = New Size(Width, Height)

        PictureBox1.Image = CType(MyImage, Image)

 

 

    End Sub