[英]How can I open an image and edit the image with C# .Net Compact Framework.
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.是否可以通过在图像上绘制来打开图像并编辑该图像,这意味着加载图像并在其上做一些划痕,就像我们在 Windows Paint 中可以做到的那样。
How can I do that in .Net Compact Framework using C# ?我如何使用 C# 在 .Net Compact Framework 中做到这一点?
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.只需使用
Image.FromFile()
打开图像,然后使用Graphics.FromImage()
针对该图像创建一个Graphics
对象,然后使用 GDI+ 方法如DrawLine()
、 DrawRectangle()
、 DrawString()
等对其进行更改. At the end, use Image.Save()
function to save your changes back to the file.最后,使用
Image.Save()
函数将更改保存回文件。
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>");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.