Steven Low
Active member
- Joined
- Apr 14, 2005
- Messages
- 42
- Programming Experience
- 1-3
Hi guys Im having probelms with the trackbar...What I like to do is to allow the track bar to resize the image.
sooo far I have mangaed to use a textfield to size the image but it wud be better with a track bar one track bar for the height and another for the width..
So far I have dun this///If possible can sumone help me to enable the code to run on a track bar or is there a better example you guys can offer me that sows me how to use 2 track bars one for the hight and width.
Thank you
' Get the scale factor.
Dim scale_factor As Single = Single.Parse(TrackBar1.Text)
' Get the source bitmap.
Dim bm_source As New Bitmap(picSource.Image)
' Make a bitmap for the result.
Dim bm_dest As New Bitmap( _
CInt(bm_source.Width * scale_factor), _
CInt(bm_source.Height * scale_factor))
' Make a Graphics object for the result Bitmap.
Dim gr_dest As Graphics = Graphics.FromImage(bm_dest)
' Copy the source image into the destination bitmap.
gr_dest.DrawImage(bm_source, 0, 0, _
bm_dest.Width + 1, _
bm_dest.Height + 1)
' Display the result.
picDest.Image = bm_dest
End Sub
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
TrackBar1.Maximum = 1.9
TrackBar1.Minimum = 0.0
End Sub
sooo far I have mangaed to use a textfield to size the image but it wud be better with a track bar one track bar for the height and another for the width..
So far I have dun this///If possible can sumone help me to enable the code to run on a track bar or is there a better example you guys can offer me that sows me how to use 2 track bars one for the hight and width.
Thank you
' Get the scale factor.
Dim scale_factor As Single = Single.Parse(TrackBar1.Text)
' Get the source bitmap.
Dim bm_source As New Bitmap(picSource.Image)
' Make a bitmap for the result.
Dim bm_dest As New Bitmap( _
CInt(bm_source.Width * scale_factor), _
CInt(bm_source.Height * scale_factor))
' Make a Graphics object for the result Bitmap.
Dim gr_dest As Graphics = Graphics.FromImage(bm_dest)
' Copy the source image into the destination bitmap.
gr_dest.DrawImage(bm_source, 0, 0, _
bm_dest.Width + 1, _
bm_dest.Height + 1)
' Display the result.
picDest.Image = bm_dest
End Sub
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
TrackBar1.Maximum = 1.9
TrackBar1.Minimum = 0.0
End Sub