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. GDI+

GDI+

Scheduled Pinned Locked Moved C#
csharpwinformsgraphicshelptutorial
10 Posts 4 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.
  • V Offline
    V Offline
    vinay_K
    wrote on last edited by
    #1

    hi Everyone I Have drawn a Sine wave using GDI+ in C# windows application, now i need to know how to zoom the Selected region.. can anyone help me? plssssss

    V 1 Reply Last reply
    0
    • V vinay_K

      hi Everyone I Have drawn a Sine wave using GDI+ in C# windows application, now i need to know how to zoom the Selected region.. can anyone help me? plssssss

      V Offline
      V Offline
      V 0
      wrote on last edited by
      #2

      an attempt: I think there are 2 main things to do. 1. Determin the X1, X2 and Y1, Y2 where you want to zoom too. These are your constraints. (recalculate) This means in the equation y = A sin (Bx - C) + D that both x and y have to be within the restraints. 2. scale your X-Y axis. if 100 pixels for Amplitude = 1 then you could set it to 200 pixels for amplitude = 1 (eg). I would recommend doing one first without scaling, if the results are correct, you can rescale the axis to reflect the entire drawing area. Hope this helps. (it's been awhile, so double check ;) )

      V.
      Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive

      V 1 Reply Last reply
      0
      • V V 0

        an attempt: I think there are 2 main things to do. 1. Determin the X1, X2 and Y1, Y2 where you want to zoom too. These are your constraints. (recalculate) This means in the equation y = A sin (Bx - C) + D that both x and y have to be within the restraints. 2. scale your X-Y axis. if 100 pixels for Amplitude = 1 then you could set it to 200 pixels for amplitude = 1 (eg). I would recommend doing one first without scaling, if the results are correct, you can rescale the axis to reflect the entire drawing area. Hope this helps. (it's been awhile, so double check ;) )

        V.
        Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive

        V Offline
        V Offline
        vinay_K
        wrote on last edited by
        #3

        I have to expand both Sine wave as well as with(in terms of pixels) of the bitmap. can i have sample code..

        C V 2 Replies Last reply
        0
        • V vinay_K

          I have to expand both Sine wave as well as with(in terms of pixels) of the bitmap. can i have sample code..

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          you just work out the sine function for every point along the way.

          Christian Graus Driven to the arms of OSX by Vista.

          1 Reply Last reply
          0
          • V vinay_K

            I have to expand both Sine wave as well as with(in terms of pixels) of the bitmap. can i have sample code..

            V Offline
            V Offline
            V 0
            wrote on last edited by
            #5

            skvs wrote:

            can i have sample code..

            will be difficult as it has been a long time I have played with it...

            V.
            Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive

            V 1 Reply Last reply
            0
            • V V 0

              skvs wrote:

              can i have sample code..

              will be difficult as it has been a long time I have played with it...

              V.
              Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive

              V Offline
              V Offline
              vinay_K
              wrote on last edited by
              #6

              Sorry i ll explain my question clearly. 1) I have drawn a Sine Wave using Graphics.DrawCurve(..); 2) Now i need to capture (X1,Y1) and (X2, Y2) Vaues on mouse down and mouse Up function, where I'm selecting a particular region of the sinusoidal wave. (may be upper half cycle). 3) So now i have the values, but i dont know how to enlarge only selected region in GDI+ C#.. plsssss help me.

              S 1 Reply Last reply
              0
              • V vinay_K

                Sorry i ll explain my question clearly. 1) I have drawn a Sine Wave using Graphics.DrawCurve(..); 2) Now i need to capture (X1,Y1) and (X2, Y2) Vaues on mouse down and mouse Up function, where I'm selecting a particular region of the sinusoidal wave. (may be upper half cycle). 3) So now i have the values, but i dont know how to enlarge only selected region in GDI+ C#.. plsssss help me.

                S Offline
                S Offline
                Simon P Stevens
                wrote on last edited by
                #7

                Your missing the point. You can't just specify that you want to zoom into an area on the form that you have already drawn, GDI doesn't support this. What you have to do, is clear the form, and redraw the area you want, but bigger. You can capture x1,y1 x2,y2 mouse coordinates by handling the mouse down or mouse click events. Now you have the values, clear the form. (by calling .Clear(); on your Graphics object, and redraw your sine wave, bigger, and just the bit within the mouse coordinates you found out. E.g if your form is 1000 pixels wide and 1000 high, and you've drawn a sign wave from 0 to 360. If the user then picks to zoom in to 0,0 (top left corner) to 500,1000 (bottom in the middle). You need to then work out that 500 represents half way, which is 180 on your x axis. And that 1000 represents the whole distance (i.e. all the way from 1 to -1), you then clear the image, and redraw the sine wave from 0 to 180, but expanded to fill the whole form. Basically, you need to store scale factors and position factors that you scale and move you sine wave by when redrawing it each time.

                Simon

                V V 2 Replies Last reply
                0
                • S Simon P Stevens

                  Your missing the point. You can't just specify that you want to zoom into an area on the form that you have already drawn, GDI doesn't support this. What you have to do, is clear the form, and redraw the area you want, but bigger. You can capture x1,y1 x2,y2 mouse coordinates by handling the mouse down or mouse click events. Now you have the values, clear the form. (by calling .Clear(); on your Graphics object, and redraw your sine wave, bigger, and just the bit within the mouse coordinates you found out. E.g if your form is 1000 pixels wide and 1000 high, and you've drawn a sign wave from 0 to 360. If the user then picks to zoom in to 0,0 (top left corner) to 500,1000 (bottom in the middle). You need to then work out that 500 represents half way, which is 180 on your x axis. And that 1000 represents the whole distance (i.e. all the way from 1 to -1), you then clear the image, and redraw the sine wave from 0 to 180, but expanded to fill the whole form. Basically, you need to store scale factors and position factors that you scale and move you sine wave by when redrawing it each time.

                  Simon

                  V Offline
                  V Offline
                  V 0
                  wrote on last edited by
                  #8

                  That was what I was thinking, but you explained it better :-)

                  V.
                  Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive

                  1 Reply Last reply
                  0
                  • S Simon P Stevens

                    Your missing the point. You can't just specify that you want to zoom into an area on the form that you have already drawn, GDI doesn't support this. What you have to do, is clear the form, and redraw the area you want, but bigger. You can capture x1,y1 x2,y2 mouse coordinates by handling the mouse down or mouse click events. Now you have the values, clear the form. (by calling .Clear(); on your Graphics object, and redraw your sine wave, bigger, and just the bit within the mouse coordinates you found out. E.g if your form is 1000 pixels wide and 1000 high, and you've drawn a sign wave from 0 to 360. If the user then picks to zoom in to 0,0 (top left corner) to 500,1000 (bottom in the middle). You need to then work out that 500 represents half way, which is 180 on your x axis. And that 1000 represents the whole distance (i.e. all the way from 1 to -1), you then clear the image, and redraw the sine wave from 0 to 180, but expanded to fill the whole form. Basically, you need to store scale factors and position factors that you scale and move you sine wave by when redrawing it each time.

                    Simon

                    V Offline
                    V Offline
                    vinay_K
                    wrote on last edited by
                    #9

                    that's a great idea, in fact it is required to draw only part of the sine wave, but how to find which are those points that i need to consider.. int intLenght = 200; PointF[] pf = new PointF[intLenght]; for (int intI = 0; intI < intLenght; intI++) { int intHeightOffset = 250; if ((intI%10) > 5) { pf[intI] = new PointF(intHeightOffset + intI, (intI % 10) + intHeightOffset); } else { pf[intI] = new PointF(intHeightOffset + intI, -(intI % 10) + intHeightOffset); } } Graphics gps = this.CreateGraphics(); gps.DrawCurve(new Pen(Color.DarkBlue), pf); if i select middle of the graph, from which point's of the array i hv to take to redraw the sine wave..? pls dont mind, i need ur help..

                    V 1 Reply Last reply
                    0
                    • V vinay_K

                      that's a great idea, in fact it is required to draw only part of the sine wave, but how to find which are those points that i need to consider.. int intLenght = 200; PointF[] pf = new PointF[intLenght]; for (int intI = 0; intI < intLenght; intI++) { int intHeightOffset = 250; if ((intI%10) > 5) { pf[intI] = new PointF(intHeightOffset + intI, (intI % 10) + intHeightOffset); } else { pf[intI] = new PointF(intHeightOffset + intI, -(intI % 10) + intHeightOffset); } } Graphics gps = this.CreateGraphics(); gps.DrawCurve(new Pen(Color.DarkBlue), pf); if i select middle of the graph, from which point's of the array i hv to take to redraw the sine wave..? pls dont mind, i need ur help..

                      V Offline
                      V Offline
                      vinay_K
                      wrote on last edited by
                      #10

                      some one had deleted me message.

                      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