Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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

like image 989
Embedd_0913 Avatar asked Feb 15 '23 05:02

Embedd_0913


1 Answers

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>");
like image 142
dotNET Avatar answered Feb 17 '23 20:02

dotNET