How can I open an image and edit the image with C# .Net Compact Framework.

天涯浪子 提交于 2021-01-27 07:26:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!