how can i zoom an image inside a picturebox? and i also want to know how can i make a picture inside the picturebox draggable while at the same time, it can be zoomed in and out.
my goal is to crop an image inside the picturebox and i can zoom and drag the image inside if necessary, thanks :)
Uncommented but free code to draw a zoomed image in a picture box with a trackbar. :)
Public Class Form1 Private TheImageOpened As Bitmap Private TheImageRectThatCanBeManipulated As Rectangle Private TrackBarCenter As Integer = 8 Sub New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. TrackBar1.Minimum = 1 TrackBar1.Maximum = 16 TrackBar1.Value = TrackBarCenter End Sub Private Sub ButtonOpenTheImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOpenTheImage.Click Dim OpenFileDialog As New OpenFileDialog OpenFileDialog.Filter = "Image Files|*.png;*.jpg;*.bmp" OpenFileDialog.FilterIndex = 0 OpenFileDialog.RestoreDirectory = True 'Fix Bad logic in Xp that will cause 'Environment.CurrentDirectory 'My.Application.Info.DirectoryPath 'to retrieve the directory of the path opened from this dialog instead of 'the app directory. If OpenFileDialog.ShowDialog = Windows.Forms.DialogResult.OK Then TheImageOpened = New Bitmap(OpenFileDialog.FileName) TheImageRectThatCanBeManipulated = New Rectangle(Point.Empty, TheImageOpened.Size) PictureBox1.Invalidate() End If OpenFileDialog.Reset() OpenFileDialog.Dispose() End Sub Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint If TheImageOpened IsNot Nothing Then e.Graphics.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic e.Graphics.DrawImage(TheImageOpened, TheImageRectThatCanBeManipulated) End If End Sub Private Sub TrackBar1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrackBar1.ValueChanged If TheImageOpened IsNot Nothing Then TheImageRectThatCanBeManipulated.Width = TheImageOpened.Width * (TrackBar1.Value / TrackBarCenter) TheImageRectThatCanBeManipulated.Height = TheImageOpened.Height * (TrackBar1.Value / TrackBarCenter) PictureBox1.Invalidate() End If End Sub End Class
OMG Unhnd_Exception, that was great! thanks! theres one more thing, how can i make the image inside the picturebox draggable while it can be zoomed in and out? because i want a certain part of the image cropped and zoomed, thanks for your answer! youre an angel! :)
I have two tables, I will call them first-half and second-half (of the year)
Table: first id jan feb mar apr ----------------------- 2 80 90 70 60 3 50 40 60 30 Table: second id jan feb mar apr ----------------------- 2 50 70 60 90 3 80 60 50 ...
i am trying to create a library management system which is supposed to be used to store/keep infp for the library and the library members( book title, author, name and picture for borrower and other stuffs). The app has 6 buttons, delete, save, add,previsous,next, and upload( for upload ...
I want to create a Alternate Coloring in MsFlexGrid that using the Visual Basic Programming.
Here I attach a source code :
MsFlexGrid I give name : Flex
If Wt <= RsParts.Fields!Lowerlimit Then
'*********************************************************** '2. Section for create Color at 1 Column under REMARK Dim lngRow As Long Dim ...