Create PNG with transparency from two files

ekhanh101

New member
Joined
Jun 8, 2009
Messages
3
Programming Experience
Beginner
Is it possible to create a PNG image with transparency,
if I have two images, original + mask = new image?
I was reading on Blitting but don't understand it.

original:
shell.jpg


mask:
shellmask.jpg


so new image will just be the shell logo itself, and the mask area becomes the transparent. Blit? or something


I'm new to this GDI stuff and not sure how to do it.

thanks.
 
looks like the mask is not all true black, found that if i raise the threshold of RGB to < 50 it works perfect. :)

just incase anyone else runs into this. :

VB.NET:
If mask_bm.GetPixel(x, y).R < 50 And mask_bm.GetPixel(x, y).G < 50 And mask_bm.GetPixel(x, y).B < 50 Then
shell50.png
 
I tried pixel/pixel comparison and make Transparent ,

VB.NET:
                    'Scan the mask image
                    For y = 0 To mask_bm.Height - 1

                        For x = 0 To mask_bm.Width - 1

                            'Check pix for transparency
                            'Response.Write(mask_bm.GetPixel(x, y).ToString() & "<br/>")

                            If mask_bm.GetPixel(x, y) = Color.FromArgb(255, 0, 0, 0) Then

                                'This pixel has transparency! Make the pixel in the pattern transparent too
                                pattern_bm.SetPixel(x, y, (Color.FromArgb(0, 0, 0, 0)))

                            End If
                        Next x
                    Next y

but not all areas get "masked" out. there's lots of noise. why is that?

Any suggestions?
shell.png



looks like the mask is not all true black, found that if i raise the threshold of RGB to < 50 it works perfect. :)

just incase anyone else runs into this. :

VB.NET:
If mask_bm.GetPixel(x, y).R < 50 And mask_bm.GetPixel(x, y).G < 50 And mask_bm.GetPixel(x, y).B < 50 Then
shell50.png
 
Back
Top