RIAS
asked on
Add zoom to picturebox
Hi,
How add a functionality of zoom in and out on picturebox in vb.net (desktop).
Code for adding image to picturebox
How add a functionality of zoom in and out on picturebox in vb.net (desktop).
Code for adding image to picturebox
Protected Friend Sub ScaleImage(ByVal p As PictureBox, ByVal i As Bitmap)
Try
p.SizeMode = PictureBoxSizeMode.AutoSize
p.Image = i
FrmMain.Panel1.AutoScroll = True
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
Hi RIAS,
Are you using Winforms or WPF? Also you want to Zoom In/Out using Mouse wheel or buttons?
Regards,
Chinmay.
Are you using Winforms or WPF? Also you want to Zoom In/Out using Mouse wheel or buttons?
Regards,
Chinmay.
ASKER
Hi,
I am using winforms vb.net desktop 2017.
On a button click it willbe great!
I am using winforms vb.net desktop 2017.
On a button click it willbe great!
ASKER
Misha,Thanks that code doesnt work for me.
What does not work? What is the errors?
ASKER
The image just disappear on mouse roll event
Set properties
PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
Panel1.AutoScroll = True
and try this code with buttons:Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
PictureBox1.Height *= 1.2
PictureBox1.Width *= 1.2
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
PictureBox1.Height *= 0.8
PictureBox1.Width *= 0.8
End Sub
Private Sub PictureBox1_LoadCompleted(sender As Object, e As System.ComponentModel.AsyncCompletedEventArgs) Handles PictureBox1.LoadCompleted
PictureBox1.Height = PictureBox1.Image.Height
PictureBox1.Width = PictureBox1.Image.Width
End Sub
End Class
no points: Misha's code works https://1drv.ms/u/s!AraFMFeqNr_BiKgZde9x3-Svk25-Qg
ASKER
Misha! Trying brb
ASKER
Misha,
It works but it keeps changing the position.
It works but it keeps changing the position.
ASKER
how can I define the picturebox location.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Misha,
Stretch looks horrible.
I will try location
Stretch looks horrible.
I will try location
Open in new window
Source:
https://stackoverflow.com/questions/13496706/how-to-zoom-in-a-picturebox-with-scrollwheel-in-vb-net