Click here to Skip to main content
15,901,666 members
Please Sign up or sign in to vote.
4.75/5 (4 votes)
See more:
hai friends
I have a webcam image and another one image. i want to stich stick external image to webcam image. I've done it but my problem is external image should be transparent to background image(webcam image). how can I make the external image as a transparent image. Help me
Posted
Updated 2-May-12 2:23am
v2
Comments
Prasad_Kulkarni 23-Apr-12 7:26am    
Nice question.

Hello

It depends on the so-called external image.

Does it have a good pure background, For example White or Black or Blue?

If yes, then use Bitmap.MakeTransparent Method(Color) Look at here

The external image format can not be JPG or BMP. It must be PNGor GIF or ...
 
Share this answer
 
v2
hey,
try this

C#
using (Image img = Image.FromFile(filename))
using (Bitmap bmp = new Bitmap(img))
{
    for (int x = 0; x < img.Width; x++)
    {
        for (int y = 0; y < img.Height; y++)
        {
            Color c = bmp.GetPixel(x, y);
            if (c.R == 255 && c.G == 255 && c.B == 255)
                bmp.SetPixel(x, y, Color.FromArgb(0));
        }
    }
    bmp.Save("out.png", ImageFormat.Png);
}


best Luck
Happy Coding
 
Share this answer
 
Comments
Prasad_Kulkarni 23-Apr-12 7:25am    
I was expecting answer from someone here. Have you tried this before?
[no name] 23-Apr-12 12:39pm    
SetPixel is way too slow... :)
Shahin Khorshidnia 2-May-12 8:32am    
Why don't use Bitmap.MakeTransparent Method (Color)?
My vote of 4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900