I have two bitmap images. One contains a picture taken with a usb camera. The other will contain a shape, like a rectagle, but it can also be a trapezoid, or lets say, a random shape with only one color in it. The rest of the image is white right now.
The two images aren't of the same size but scaling algorithms aren't the most difficult part here, so lets assume they are of the exact same dimensions.
I want to show my shape on the usb camera picture. The white part will be considered as transparent for the combinaison purpose. Right now I'm thinking of editing the image pixels by pixels, but I'm searching for an API which will do it for me.
So if I take a picture with a house in the middle of it and overlay a red rectagle, the resulting image will have the original picture with a red rectangle around the house.
I'm using .NET if this can help. I could also use win32 API if it contains some useful functions.
Edit : I accepted the answer since it put me on the right track. This is actually super easy to do.
Bitmap^ overlay_image = gcnew Bitmap("overlay.bmp");
Bitmap^ original_image = gcnew Bitmap("original.bmp");
overlay_image->MakeTransparent(Color::White);
Graphics^ g_original = Graphics::FromImage(original_image);
g_original->DrawImage(overlay_image, 0, 0);
Voilà, original_image
now has a red rectangle over it. It is actually fast enough for my 30fps usb camera so I can get it in real time.
There is no scaling done right now. Also, it assumes that the overlay image background is white, which will be made transparent.