0

i have the following code to generate my bitmap image using C#. i just want to know how i can save the output image to my desktop directory instead of showing to my picture box?

 Image bmp = new Bitmap(100, 100); Graphics g = Graphics.FromImage(bmp); g.DrawString(randomString, myFont, new SolidBrush(Color.Black), new PointF(0, 0)); pictureBox1.Image = bmp; 
3
  • how are g and bmp related? You might glean something here stackoverflow.com/questions/12909905/saving-image-to-file Commented Jan 25, 2014 at 22:20
  • only that? no more syntax and where doeas it save the image? Commented Jan 25, 2014 at 22:29
  • 1
    @CowBoy Just type Image.Save to google and go the first msdn link. It also contains an example. Is this so hard? Commented Jan 25, 2014 at 22:45

1 Answer 1

0

Try this: pictureBox1.Image.Save("your path", ImageFormat.your_format);

You will need this reference: using System.Drawing.Imaging;

Sign up to request clarification or add additional context in comments.

7 Comments

when you write ImageFormat. intelliSense should give you suggestions, for example ImageFormat.Jpeg
do i need to add any reference? and what can i put to save it for example on my desktop (general address that works for all computer)
@CowBoy answered that in an edit. Add: using System.Drawing.Imaging;
i got it cool! but it doeasnt save it, i put "C:\Users\M.R.B\Desktop" but its giving me error
@CowBoy Probably that is the default bitmap color. Try this g.Clear(Color.White) before writing text.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.