08-18-2010, 10:35 AM
Thought this may be helpful to some.. A few things that you can do using a PictureBox control:
Zoom Out:
Zoom In:
Rotate:
Thanks,
- Jack
Zoom Out:
Code:
Try
Dim scale_factor As Single = Single.Parse(2)
Dim source As New Bitmap(PictureBox1.Image)
Dim dest As New Bitmap(CInt(source.Width / scale_factor), CInt(source.Height / scale_factor))
Dim gr_dest As Graphics = Graphics.FromImage(dest)
gr_dest.DrawImage(source, 0, 0, _
dest.Width + 1, _
dest.Height + 1)
PictureBox1.Image = dest
Catch
End Try
Zoom In:
Code:
Try
Dim scale_factor As Single = Single.Parse(2)
Dim source As New Bitmap(PictureBox1.Image)
Dim dest As New Bitmap(CInt(source.Width * scale_factor), CInt(source.Height * scale_factor))
Dim gr_dest As Graphics = Graphics.FromImage(dest)
gr_dest.DrawImage(source, 0, 0, _
dest.Width + 1, _
dest.Height + 1)
PictureBox1.Image = dest
Catch
End Try
Rotate:
Code:
Dim wid As Integer
Dim hgt As Integer
Dim X As Integer
Dim Y As Integer
Dim input As New Bitmap(PictureBox1.Image)
wid = input.Width
hgt = input.Height
Dim output As New Bitmap(hgt, wid)
For X = 0 To wid - 1
For Y = 0 To hgt - 1
output.SetPixel(hgt - Y - 1, X, _
input.GetPixel(X, Y))
Next Y
Next X
PictureBox1.Image = output
Thanks,
- Jack