如何使用C#.Net Compact Framework打开图像并编辑图像. [英] How can I open an image and edit the image with C# .Net Compact Framework.

查看:45
本文介绍了如何使用C#.Net Compact Framework打开图像并编辑图像.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过在图像上进行绘制来打开图像并编辑该图像,这意味着可以加载图像并对其进行一些划痕,就像我们可以在Windows Paint中做到的那样.

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.

如何在使用C#的.Net Compact Framework中做到这一点?

How can I do that in .Net Compact Framework using C# ?

推荐答案

当然可以.只需使用 Image.FromFile()打开图像,然后使用 Graphics.FromImage()针对该图像创建一个 Graphics 对象,然后使用GDI +方法(如 DrawLine() DrawRectangle() DrawString()等)进行更改.最后,使用 Image.Save()函数将所做的更改保存回文件.

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.

以下几行内容:

Image img = Image.FromFile("<FILE_PATH>");
using (Graphics g = Graphics.FromImage(img))
    g.DrawLine(Pens.Black, 10,10, 20,20);
img.Save("<FILE_PATH>");

这篇关于如何使用C#.Net Compact Framework打开图像并编辑图像.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆