问题
Is it possible to open an image and edit that image by drawing on the image, means loading an image and just making some scratches on it like we can do that in Windows Paint.
How can I do that in .Net Compact Framework using C# ?
回答1:
Of course you can. Simply open the image using Image.FromFile()
, then create a Graphics
object against this image by using Graphics.FromImage()
and then use GDI+ methods like DrawLine()
, DrawRectangle()
, DrawString()
etc. to make changes to it. At the end, use Image.Save()
function to save your changes back to the file.
Something on the following lines:
Image img = Image.FromFile("<FILE_PATH>");
using (Graphics g = Graphics.FromImage(img))
g.DrawLine(Pens.Black, 10,10, 20,20);
img.Save("<FILE_PATH>");
来源:https://stackoverflow.com/questions/18890964/how-can-i-open-an-image-and-edit-the-image-with-c-sharp-net-compact-framework