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. Saving an self painted image from a pictureBox

Saving an self painted image from a pictureBox

Scheduled Pinned Locked Moved C#
graphicsquestionlearning
3 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.
  • M Offline
    M Offline
    MyPiano
    wrote on last edited by
    #1

    Hello, I'm programming a little music helper and use the System.Drawing class, to draw the staves and notes on a PictureBox. I want to save that as Image, but all my attempts failed. Of course I used Google to find the answer and I found a advice. It says that I have to draw my things on a Bitmap first and save that. But How do I draw something on a Bitmap with Graphics? I'm looking forward to your answers. Best regards MyPiano(Joris) edit: Sorry for my English. It isn't my mother-tongue.

    A 1 Reply Last reply
    0
    • M MyPiano

      Hello, I'm programming a little music helper and use the System.Drawing class, to draw the staves and notes on a PictureBox. I want to save that as Image, but all my attempts failed. Of course I used Google to find the answer and I found a advice. It says that I have to draw my things on a Bitmap first and save that. But How do I draw something on a Bitmap with Graphics? I'm looking forward to your answers. Best regards MyPiano(Joris) edit: Sorry for my English. It isn't my mother-tongue.

      A Offline
      A Offline
      Ajay k_Singh
      wrote on last edited by
      #2

      Drawing anything in a Bitmap using a Graphics object is very easy. You will need to first create one bitmap object and use it for initializing graphics object. Once you get one graphics object created using FromImage method, you may draw anything in this graphics object and it will be drawn on bitmap also. At last you may save the bitmap using Save method of bitmap object. Such as- ----------Start Code---------------- Bitmap a = new Bitmap(400, 300); Graphics g = Graphics.FromImage(a); g.DrawLine(Pens.AliceBlue, 0, 0, 100, 100); a.Save(“C:\MyFile.jpg”); --------------End Code-------------- I hope this helps:). -Dave.

      Dave Traister, ComponentOne LLC. www.componentone.com

      M 1 Reply Last reply
      0
      • A Ajay k_Singh

        Drawing anything in a Bitmap using a Graphics object is very easy. You will need to first create one bitmap object and use it for initializing graphics object. Once you get one graphics object created using FromImage method, you may draw anything in this graphics object and it will be drawn on bitmap also. At last you may save the bitmap using Save method of bitmap object. Such as- ----------Start Code---------------- Bitmap a = new Bitmap(400, 300); Graphics g = Graphics.FromImage(a); g.DrawLine(Pens.AliceBlue, 0, 0, 100, 100); a.Save(“C:\MyFile.jpg”); --------------End Code-------------- I hope this helps:). -Dave.

        Dave Traister, ComponentOne LLC. www.componentone.com

        M Offline
        M Offline
        MyPiano
        wrote on last edited by
        #3

        Hey Dave, Thanks for your help. It works great now! :) Best regards Joris

        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