Image Zoom Using VB.NET

Image Zoom Using VB.NET post thumbnail image
In this post we learn to apply Zoom Effect on the Specified Image.

o TrackBar
o PictureBox
o ContextMenuStrip
o OpenFileDialog
Step 1:
/*——————————–Setting Properties————————*/
Form Properties
ContextMenustrip =ContextMenuStrip1
TrackBar Properties
LargeChange =1
Maximum =20
Minimum =1
Value =1
PictureBox Properties
SizeMode =AutoSize
Dock =None
Image =None
Add 2 menu labled as follows…
menu: load image
Step 2:
/*——————————–Writing Codes————-—————-*/
TrackBar1_Scroll Event
Dim scale As Double= TrackBar1.Value
Dim height As Integer = Convert.ToInt32(scale * ptbImage.Image.Height)
Dim width As Integer = Convert.ToInt32(scale * ptbImage.Image.Width)
‘Apply new size according to TrackBar Value to PictureBox
ptbImage.Size = New Size(width, height)
ptbImage.SizeMode = PictureBoxSizeMode.StretchImage
ExitToolStripMenuItem_Click Event
LoadImageToolStripMenuItem_Click Event
Dim res As DialogResult
‘Setting Image filter to OpenFileDialog Control
OpenFileDialog1.Filter = “JPEG|*.jpg|BMP|*.bmp|All Files|*.*”
res = OpenFileDialog1.ShowDialog()
‘Select the Image File
If res = Windows.Forms.DialogResult.OK Then
ptbImage.Image = Image.FromFile(OpenFileDialog1.FileName)
End If
‘Adjust the Size of Image
ptbImage.SizeMode = PictureBoxSizeMode.AutoSize
Step 3:
/*——————————–Execution of Program—————————–*/

Mayur Dighe

Leave a Reply

Your email address will not be published. Required fields are marked *