CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 1999
    Posts
    1

    How to implement zooming capabilities on graphics?

    I am creating an image viewer, and I would like to know how to implement zooming capability on a graphic displayed in a picture box: eg: 25%,50% 100%, 110% etc. (25% being the smallest and 100% being the actual size (No strech)). Also, if the actual size of the picture is greater than its container when it is loaded, the vertical and horizontal bar should appear automatically!

    Thanks


  2. #2
    Guest

    Re: How to implement zooming capabilities on graphics?



    option Explicit 'Just to let you know where we are...
    Dim intSize as Integer

    'Put this code in the event you want to zoom away on:
    'Zooming in...
    intSize = intSize + 1
    If intSize < 0 then
    if intSize = -1 then
    intSize = -2
    end if
    Dim picPic as Picture
    set picPic = picPictureBox.Picture
    picPictureBox.Picture = LoadPicture()
    picPictureBox.PaintPicture(picPic, 0, 0, (-1) * picPictureBox.Width / intSize, (-1) * picPictureBox.Height / intSize)
    'This should handle the zooming in...
    else
    if intSize = 0 then
    intSize = 1
    end if
    Dim picP as Picture
    set picP = picPictureBox.Picture
    picpicturebox.Picture = LoadPicture()
    picPictureBox.PaintPicture(picP, 0, 0, intSize * picPictureBox.Width, intSize * picPictureBox.Height)
    end if





    There you go, enjoy.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured