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. export to bitmap

export to bitmap

Scheduled Pinned Locked Moved C#
graphicswinformshelptutorial
5 Posts 2 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.. 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

    G 1 Reply Last reply
    0
    • V vinay_K

      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

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      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.

      V 1 Reply Last reply
      0
      • G Guffa

        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.

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

        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..?

        G 1 Reply Last reply
        0
        • V vinay_K

          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..?

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          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.

          V 1 Reply Last reply
          0
          • G Guffa

            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.

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

            ok i got it, i tried in the way how u sugessted me.. now im having two bitmap object's, one containing scale & other one containing waveform. how to combine these 2 bitmap objects to plot it as one bitmap image on the screen..

            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