Click here to Skip to main content
15,867,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi I am looking for download able source code.
It must be like:
http://www.codeproject.com/KB/graphics/drawtools.aspx?msg=3668999
That is working perfectly but sadly this project can't save result in JPG or GIF format...

I want a user to create an plain image using rectangles and ellipses and save it in jpg fromat.

Kind regards
Heinrich
Posted
Updated 17-Nov-10 19:09pm
v2

You could use the project from the link you posted and then use the

drawArea.DrawToBitmap()


method to create a bitmap. This bitmap can then be saved as*.bmp, *.jpg...

Ok,

here is an example:

C#
private void toolStripButtonSave_Click(object sender, EventArgs e)
{
  int w = drawArea.Width;
  int h = drawArea.Height;
  Bitmap bmp = new Bitmap(w, h);
  drawArea.DrawToBitmap(bmp, Rectangle.FromLTRB(0, 0, w, h));
  bmp.Save("C:\\Temp\\test.jpg");
  CommandSave();
}


As you can see I modified the event handler for the "Save" toolbar button. I have tested it and it works fine!
 
Share this answer
 
v2
Comments
heinrich4J 18-Nov-10 1:50am    
Problem is that this is in VB and the other code is in C#
Would i still be able to implement it this way?
JF2015 18-Nov-10 1:56am    
If you need this code in VB, then you would need to rewrite it completely since the whole DrawArea control of this project was written in C# and thus can not be easily used with VB. But since you have all the source it should not be that hard.
heinrich4J 18-Nov-10 2:28am    
sorry, i think i explainded wrong, i want to keep in in C#, Testing it now
Thanks for the help so far!
heinrich4J 18-Nov-10 2:34am    
Could you please add the code in the project and email me the zip? :)
I cant get it to work....(my skills are letting me donw)....
heinrich4J 18-Nov-10 2:41am    
heinrichh at gwk.co.za
Thanks for the reply
how would i use the "drawArea.DrawToBitmap()"
where would it put it in?

kind regards
 
Share this answer
 
Comments
JF2015 18-Nov-10 1:46am    
See my updated answer. And please, if you want to ask something about my answer, post a comment to the answer instead posting an answer to your question - this way I won't be notified of your question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900