Opt In (Do Not Edit Here)

Showing posts with label Image Control. Show all posts
Showing posts with label Image Control. Show all posts

Oct 25, 2015

Image Zoom Using VB.NET

In this post we learn to apply Zoom Effect on the Specified Image.
Requirements:
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
ContextMenuStrip
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
Application.Exit()
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-----------------------------*/

All Rights Reserved. 2014 Copyright SIMPLITONA

Powered By Blogger | Published By Gooyaabi Templates Designed By : BloggerMotion

Top