This explains how to open up standard images in VB
This is only simple and does not have rich features.
It only shows how to load an image using the openfiledialog
1.Open VB 05 Express
2.CLick New Project
3.Make sure Windows Application is selected
4.Name it Image Reader
5.Rename Form1.vb to MainForm.vb
6.Change the properties of MainForm stated here:
MainForm Properties
Text = Image Reader
MaximizeBox = False
MinimizeBox = False
Size
-Width = 828
-Height = 599
7.Drag a button on the form and change the properties
Button Properties
Name = btnOpen
Text = Open Image
FlatStyle = Popup
Location = (X=323, Y=12)
8.Drag a Picture Box and change its properties
Picture Box Properties
Name = pBoxImage
Size = (Width = 796) (Height = 502)
BackColor = Web White
SIzeMode = Stretch Image
-------------------------------------------------
Your Form should look like this
Now from the toolbox and drag an OpenFileDialog to the form.
Select it on the Component Tray and change the properties.
Name = OpenImage
FileName = Supported Types
Now double-click the button.
It should bring you to the code editor and have the button event handler
written already
Now Type The Following Code
Code: Select all
' This code handles when the user clicks the button
OpenImage.Filter = " Bitmaps (*.bmp)|*.bmp|GIF (*.gif)|*.gif|JPG _ (*.jpg)|*.jpg|JPEG (*.jpeg)|*.jpeg|PNG (*.png)|*.png|TIFF _(*.TIFF|*.TIFF "
If OpenImage.ShowDialog() = Windows.Forms.DialogResult.OK_ Then_
pBoxImage.Image = System.Drawing.Image.FromFile_(OpenImage.FileName)
End If
The code makes all the supported file type the program will open.
Then it shows the open file dialog.
Then the user navigates to the supported image. The image is then
passed to pBoxImage and shows the image and stretches it out so you can
see it in one box.
Thats it, next time I will try to post how to save the image.