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
#2
Thanks for this tutorial.
This can be helpful for Photo Viewer. Oui
[Image: di-0ECG.png]
Reply
#3
This is some amazing functions :o Nice work !
My only goal is to help other people .
[Image: gNQgw]
How to make a Photo Viewer [HQ]
Reply
#4
That's downright sexy! Thanks man!
Reply
#5
Nice bro Smile
Everyone seems to be posting about photoviewers latley
[Image: blanktemplate.png]
Reply
#6
Thanks mate for this. Great source Big Grin
Reply
#7
Glad you all found this useful.
Reply
#8
Can you explain the rotate part? I find it hard to understand and I don't like just copy-pasting code.
My software company: Porosis Software
Games: Terrantula
Apps: Mathanasis, ColorGrabber
Reply
#9
thanks for the tutorial

very useful Smile
Reply


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

Forum Jump:


Users browsing this thread: 1 Guest(s)