Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Source] Tricks Using PictureBox Control [VB.NET]
#1
Thought this may be helpful to some.. A few things that you can do using a PictureBox control:

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
Reply


Messages In This Thread
[Source] Tricks Using PictureBox Control [VB.NET] - by Fragma - 08-18-2010, 10:35 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [VB.NET] Advanced MessageBox Control BlackSpider 14 11,189 03-04-2015, 11:22 PM
Last Post: longwest
  Free Advanced Port Scanner SOURCE [ VB.NET ] Filefinder 6 5,330 01-22-2013, 04:27 AM
Last Post: TalishHF
  vb6.0 SSTab control disappeared DanB 0 1,193 12-29-2012, 10:24 AM
Last Post: DanB
  [VB.NET]Console app Menu example (amortization calculator)[Source] KoBE 8 7,597 12-28-2012, 06:55 AM
Last Post: mouse719
  [VB.NET] Get Region Info [Source] ƃu∀ ıʞƃu∀ 0 1,110 11-28-2012, 04:38 AM
Last Post: ƃu∀ ıʞƃu∀

Forum Jump:


Users browsing this thread: 1 Guest(s)