Friday, January 13, 2006

Overlaying an image overtop of another image

Recently I was asked to build a website that when a property got sold a little sold sticker appeared in the upper corner of the image. I thought this would be really hard based on my experience with php image manipulation. With .NET and GDI+ it was so easy. Here it is:

Dim baseImage As Image
Dim overlayImage As Image
baseImage = Image.FromFile("c:\house.jpg")
overlayImage = Image.FromFile("c:\loginButton.jpg")

Dim gr As Graphics
gr = Graphics.FromImage(baseImage)
gr.DrawImage(overlayImage, 10, 10)

Me.PictureBox1.Image = baseImage

This is easy to change to load from a stream / save it to a web output stream (baseImage.Save(Response.OutputStream)).


Post a Comment

<< Home