GDI+
-
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
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 -
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 -
I have to expand both Sine wave as well as with(in terms of pixels) of the bitmap. can i have sample code..
you just work out the sine function for every point along the way.
Christian Graus Driven to the arms of OSX by Vista.
-
I have to expand both Sine wave as well as with(in terms of pixels) of the bitmap. can i have sample code..
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 -
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 ArchiveSorry 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.
-
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.
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
-
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
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 -
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
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.. -
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..