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