Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to move and zoom an image?

How to move and zoom an image?

Scheduled Pinned Locked Moved C#
helptutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jinzhecheng
    wrote on last edited by
    #1

    If you have used Autocad , you must know how convenient it is to use "pan",Zoom in realtime. I am wondering how can we move an image inside a picture box, after zoom in or our. Can Anyone help? jim:laugh:

    L 1 Reply Last reply
    0
    • J jinzhecheng

      If you have used Autocad , you must know how convenient it is to use "pan",Zoom in realtime. I am wondering how can we move an image inside a picture box, after zoom in or our. Can Anyone help? jim:laugh:

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      Look at Graphics.Transform, should be all you need :) ie

      float scale = percentagezoom/100f;
      g.Transform = new Matrix(scale,0,0,scale, xoffest, yoffset);

      xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

      J N 2 Replies Last reply
      0
      • L leppie

        Look at Graphics.Transform, should be all you need :) ie

        float scale = percentagezoom/100f;
        g.Transform = new Matrix(scale,0,0,scale, xoffest, yoffset);

        xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

        J Offline
        J Offline
        jinzhecheng
        wrote on last edited by
        #3

        thank ya leppie, after several hour , I got it worked, //////////////////// everyone is my teacher

        1 Reply Last reply
        0
        • L leppie

          Look at Graphics.Transform, should be all you need :) ie

          float scale = percentagezoom/100f;
          g.Transform = new Matrix(scale,0,0,scale, xoffest, yoffset);

          xacc-ide 0.0.15 now with C#, MSIL, C, XML, ASP.NET, Nemerle, MyXaml and HLSL coloring - Screenshots

          N Offline
          N Offline
          NortonC
          wrote on last edited by
          #4

          Hi, I'm quite new to C# especially when using GDI+. I saw the solution for zooming an image, but I didn't manage to zoom. I couldn't quite understand what the parameters in "new Matrix(scale,0,0,scale, xoffest, yoffset);" mean I think :) In order to zoom my image by 25% I implemented your code in the following way: float scale = 25f/100f; pictureBox.Image.Save("OriginalImage.png",ImageFormat.Png); Graphics g = Graphics.FromImage(pictureBox.Image); g.Transform = new Matrix(scale,0,0,scale, 0, 0); pictureBox.Image.Save("ResizedImage.png", ImageFormat.Png); pictureBox.Image = Image.FromFile("ResizedImage.png"); //to load the new image What am I doing wrong please? Thanks A Lot! C.N.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups