Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding a watermark image to an image

I want to add a small, kind of fading out watermark image to all my images.

is there a way to do this in c#?

like image 499
mrblah Avatar asked Dec 22 '09 22:12

mrblah


People also ask

How do I add a watermark to a PNG?

Press and hold down the ALT key, then type the numbers 0169 on your number keypad. Release ALT, and the copyright symbol should appear. Add text to the copyright symbol if you want the copyright watermark to include more information.


1 Answers

You can compose images using System.Drawing

//1. create a bitmap (create a empty one or from file)
Bitmap bmpPic = new Bitmap(imgWidth,imgHeight);

//2. pass that bitmap into Graphics
using (Graphics g = Graphics.FromImage(bmpPic))
{
    //manipulate the image
}

//3. save the bitmap back to a filestream
bmpPic.Save(imgFileStream,ImageFormat.Png);

Just make sure to dispose all resources used as System.Drawing uses unmanaged GDI+ resources

like image 90
mkeil Avatar answered Oct 16 '22 02:10

mkeil