Make a Picture Converter in VB 2008
Posted: Mon Jun 07, 2010 1:20 pm
Hi there,
I tried to make a pic converter and after spending 4 hours i got it...
Today i am going to show how to make a Picture Converter
You Need
2 Buttons ( Button 1 "Open File" Button 2 "Convert To")
1 ComboBox ( Add PNG JPEG GIF BMP ICO)
1 Label
1 Picture Box
1 OpenFileDialog
1 SaveFileDialog
Now add the Following Code to Open File Button
Regards
Shahbaz Singh
I tried to make a pic converter and after spending 4 hours i got it...
Today i am going to show how to make a Picture Converter
You Need
2 Buttons ( Button 1 "Open File" Button 2 "Convert To")
1 ComboBox ( Add PNG JPEG GIF BMP ICO)
1 Label
1 Picture Box
1 OpenFileDialog
1 SaveFileDialog
Now add the Following Code to Open File Button
Code: Select all
Now Add the Following Code to Convert to ButtonPrivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
PictureBox1.Image = System.Drawing.Image.FromFile(OpenFileDialog1.FileName)
End If
Catch ex As Exception
End Try
End Sub
Code: Select all
Hope You Got it..If ComboBox1.SelectedItem = "JPEG" Then
SaveFileDialog1.Filter = "JPEG |*.jpg"
Try
If SaveFileDialog1.ShowDialog = DialogResult.OK Then
PictureBox1.Image.Save(SaveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg)
End If
Catch ex As Exception
End Try
End If
Try
If ComboBox1.SelectedItem = "ICO" Then
SaveFileDialog1.Filter = "ICO |*.ico"
If SaveFileDialog1.ShowDialog = DialogResult.OK Then
PictureBox1.Image.Save(SaveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Icon)
End If
End If
Catch ex As Exception
End Try
If ComboBox1.SelectedItem = "PNG" Then
SaveFileDialog1.Filter = "PNG |*.png"
Try
If SaveFileDialog1.ShowDialog = DialogResult.OK Then
PictureBox1.Image.Save(SaveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Png)
End If
Catch ex As Exception
End Try
End If
If ComboBox1.SelectedItem = "GIF" Then
SaveFileDialog1.Filter = "GIF |*.gif"
Try
If SaveFileDialog1.ShowDialog = DialogResult.OK Then
PictureBox1.Image.Save(SaveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Gif)
End If
Catch ex As Exception
End Try
End If
If ComboBox1.SelectedItem = "BMP" Then
SaveFileDialog1.Filter = "BMP |*.bmp"
Try
If SaveFileDialog1.ShowDialog = DialogResult.OK Then
PictureBox1.Image.Save(SaveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
End If
Catch ex As Exception
End Try
End If
End Sub
Regards
Shahbaz Singh