Click here to Skip to main content
14,774,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i may use Graphics.DrawImage to draw an available Image on a Graphics. but i want to make an Image which is not available by drawing lines, rectangles, texts, etc. on a Graphics.
how is it possible in C#?
in C++, it's possible to create a bitmap which is compatible with the window DC and creating a compatible dc with the window DC called memory DC and selecting the bitmap in the memory dc. further graphical operations are done on the selected bitmap. then i have a CBitmap object which includes the made shape.
now in C# how can i do that?
the aim is to save a drawn shape to a file.
thx
Posted

1 solution

You can create a System.Drawing.Graphics object that is bound to an image instead of the screen. Drawing with this Graphics results in drawing on the image you used to create it (System.Drawing.Graphics.FromImage()[^]).
   
Comments
ilostmyid2 10-Jan-12 7:35am
   
thank u :)
i did what u suggested and it worked. but there's an effect in the drawn text on the image.
see my sample code pls:
http://www.4shared.com/zip/3LUzyfzg/901020_-_imgTest.html
lukeer 11-Jan-12 3:21am
   
For getting useful answers here, it's more beneficial to post the relevant code portion here. Use your original question's "Improve question" link for that and put your code between <pre lang="c#"> and </pre> tags.
And please, use proper English (capitalization, punctuation, no txtspeak) as long as you have the ability to do so (many foreign language speakers here).
ilostmyid2 11-Jan-12 3:24am
   
i've included the whole project in the link!
lukeer 11-Jan-12 4:36am
   
That makes it very unlikely that anyone will dig through it to find a solution for you. It's common practice to augment a question with the smallest possible piece of code that resembles the error you are facing. This link[^] could be helpful to read.
ilostmyid2 11-Jan-12 8:30am
   
oh! that was a great note. thx.
but just a bit of code may not be enough for regenerating the problem and others must expense in time to rebuild the project with the same operation and bug.

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