Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed an image into another image using C#?

Tags:

c#

.net-2.0

In my project user will upload an image and the logo of project will be attached(Embeded) to the bottom of the image.

Is it possible to implement?

If yes then how to implement that?

Please help.

like image 501
Himadri Avatar asked Sep 06 '25 03:09

Himadri


2 Answers

Yes it is possible to implement.

Look at the System.Drawing namespace.

You can use the Bitmap class - it will allow you to load images from files.

Create two bitmaps, one from each image then you should be able to impose the logo image onto the other one.

This is one fun example of how to do it:

Image backImg = Image.FromFile("bg.jpg");
Image mrkImg = Image.FromFile("watermark.png");
Graphics g = Graphics.FromImage(backImg);
g.DrawImage(mrkImg, backImg.Width/2, 10);
backImg.Save("result.jpg");
like image 184
Oded Avatar answered Sep 08 '25 00:09

Oded


Some people call this watermarking, I would search around for that.

Have a look at http://www.codeproject.com/KB/GDI-plus/watermark.aspx

like image 27
Mark Redman Avatar answered Sep 08 '25 00:09

Mark Redman