export to bitmap
-
hi.. I'm using Splitcontainer and drawing a sine wave using GDI+ object on the panel2 of the Splitcontainer, now i need to capture the sinewave in panel2 and save it to bit map.. so pls help me how to capture and save the waveform (panel2 contents) into the bitmap. if possible, pls provide me some reference links.. thanks in advance vinay
-
hi.. I'm using Splitcontainer and drawing a sine wave using GDI+ object on the panel2 of the Splitcontainer, now i need to capture the sinewave in panel2 and save it to bit map.. so pls help me how to capture and save the waveform (panel2 contents) into the bitmap. if possible, pls provide me some reference links.. thanks in advance vinay
You can't capture what you have drawn, as there is no guarantee at all that it's still on the screen, or even that it was actually drawn on the screen in the first place. Create a Bitmap with the same size of the control, use Graphics.FromImage to get a Graphics object to draw on the bitmap, and use the same code that you are using to draw on the panel to draw on the Bitmap.
Despite everything, the person most likely to be fooling you next is yourself.
-
You can't capture what you have drawn, as there is no guarantee at all that it's still on the screen, or even that it was actually drawn on the screen in the first place. Create a Bitmap with the same size of the control, use Graphics.FromImage to get a Graphics object to draw on the bitmap, and use the same code that you are using to draw on the panel to draw on the Bitmap.
Despite everything, the person most likely to be fooling you next is yourself.
hi..
PointF[] pfTempData = GetCalculatedPoints(intIndex);
panel2Graphics.DrawCurve(new Pen(Color.Black, 0F), pfTempData);
im using the above code to draw a sine wave, but how to draw the same onto bitmap. i tried like this
Panel2Graphics.DrawImage(bmpExport, pfTempData);
but gives as error like
{System.ArgumentException: Destination points must be an array with a length of 3 or 4. A length of 3 defines a parallelogram with the upper-left, upper-right, and lower-left corners. A length of 4 defines a quadrilateral with the fourth element of the array specifying the lower-right coordinate. at System.Drawing.Graphics.DrawImage(Image image, PointF[] destPoints) at GDIWaveformViewer2.PlotPanel.DrawGraph(Graphics gPanel2Graphics) in D:\Documents and Settings\vinayakumark\Desktop\Viewer-18july\Viewer\PlotPanel.cs:line 327}
please suggest me what to do..? -
hi..
PointF[] pfTempData = GetCalculatedPoints(intIndex);
panel2Graphics.DrawCurve(new Pen(Color.Black, 0F), pfTempData);
im using the above code to draw a sine wave, but how to draw the same onto bitmap. i tried like this
Panel2Graphics.DrawImage(bmpExport, pfTempData);
but gives as error like
{System.ArgumentException: Destination points must be an array with a length of 3 or 4. A length of 3 defines a parallelogram with the upper-left, upper-right, and lower-left corners. A length of 4 defines a quadrilateral with the fourth element of the array specifying the lower-right coordinate. at System.Drawing.Graphics.DrawImage(Image image, PointF[] destPoints) at GDIWaveformViewer2.PlotPanel.DrawGraph(Graphics gPanel2Graphics) in D:\Documents and Settings\vinayakumark\Desktop\Viewer-18july\Viewer\PlotPanel.cs:line 327}
please suggest me what to do..?You are trying to draw the bitmap on the panel, which is pretty much the opposite of what you want to do... You get that exception because you are using the wave coordinates as the bounds for where the bitmap is drawn on the panel. Use the Graphics.FromImage method as I suggested, so that you get a Graphics object that you can use to draw on the bitmap. Then you just draw the wave on the bitmap the same way that you draw it on the screen.
Despite everything, the person most likely to be fooling you next is yourself.
-
You are trying to draw the bitmap on the panel, which is pretty much the opposite of what you want to do... You get that exception because you are using the wave coordinates as the bounds for where the bitmap is drawn on the panel. Use the Graphics.FromImage method as I suggested, so that you get a Graphics object that you can use to draw on the bitmap. Then you just draw the wave on the bitmap the same way that you draw it on the screen.
Despite everything, the person most likely to be fooling you next is yourself.