Adding GraphicsPath to Bitmap?

  • Thread starter Thread starter jay
  • Start date Start date
J

jay

I have a bitmap and a graphicspath object. I draw pixels on m_Bitmap and I'm
drawing text using m_Graphics GraphicsPath object.

However, saving my work with m_Bitmap.Save doesn't save GraphicsPath along
with it.

How do I save it all in a single file? Or how do I "glue" graphicspath to
bitmap so they save together?

thanks,
jay
 
If you're intention is to modify a bitmap with graphics in the path then you
need to obtain the Graphics object for the bitmap using Graphics.FromImage,
draw the GraphicsPath to that image using DrawPath or FillPath and then save
the image to a file.

Bitmap bm=Bitmap.FromFile(filename);
Graphics g=Graphics.FromImage(bm);
GraphicsPath pth=new GraphicsPath();
pth.AddEllipse(10,10,200,150);
g.FillPath(Brushes.Yellow,pth);
g.DrawPath(Pens.Black,pth);
g.Dispose();
bm.Save(anotherfilename,ImageFormat.jpeg);

DISCLAIMER: late at night, not compiled, hope you get the picture, (pun
intended)

--
Bob Powell [MVP]
Visual C#, System.Drawing

The Image Transition Library wraps up and LED style instrumentation is
available in the June of Well Formed for C# or VB programmers
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top