Here is another example of http://www.codeproject.com/KB/web-image/ASPImaging1.aspx from codeproject, which you can do a lot on the image, including adding a watermark from the image.
I think this process requires the processor power ether to be on php, ether on asp.net. Thus, the image cache scheme is mandatory for this kind of work.
Here is the basic code. In this code, you need to change the position of the watermark and the size of the images. A watermark can be a transparent PNG image.
public void MakePhoto(...parametres...) { Bitmap outputImage = null; Graphics g = null; try { // the final image outputImage = new Bitmap(OutWidth, OutHeight, PixelFormat.Format24bppRgb); g = Graphics.FromImage(outputImage); g.CompositingMode = CompositingMode.SourceCopy; Rectangle destRect = new Rectangle(0, 0, OutWidth, OutHeight); // the photo using (var BasicPhoto = new Bitmap(cBasicPhotoFileOnDisk)) { g.DrawImage(BasicPhoto, destRect, 0, 0, BasicPhoto.Width, BasicPhoto.Height, GraphicsUnit.Pixel); } g.CompositingMode = CompositingMode.SourceOver; // the watermark using (var WaterMark = new Bitmap(cWaterMarkPhotoOnDisk)) { Rectangle destWaterRect = new Rectangle(0, 0, OutWidth, OutHeight); g.DrawImage(WaterMark, destWaterRect, 0, 0, OutWidth, OutHeight, GraphicsUnit.Pixel); } outputImage.Save(TheFileNameTosaveIt, ImageFormat.Jpeg); } catch (Exception x) { Debug.Assert(false); ... log your error, and send an error image.... } finally { if (outputImage != null) outputImage.Dispose(); if (g != null) g.Dispose(); } }
If you want to create a custom descriptor, the above code is worth it, but you only change the save line. Sort of.
public void ProcessRequest (HttpContext context) { context.Response.ContentType = "image/jpeg";