Image operations

timmy013

New member
Joined
May 28, 2012
Messages
2
Programming Experience
5-10
Hi,

I have a few transparent .png images with same size and want to add or subtract them one of other and then put the image to picturebox.

First picture:
1.JPG

Second picture which contains white pixels (or it could be black pixels) which should be erased from first picture:
2.JPG

The result should look like this:
3.JPG

Is there any way to this fast, but not looping through pixels? BitBlt using?
Some code example, please.

Thanks
 
Last edited:
I have managed to solve this problem, but had to make some changes.

Second picture, which used to be white mask - have to be changed to be consisted of pixels that are in color that don't exist on source picture. So, I have change the mask picture - white pixels are changed to HotPink pixels
4.JPG

This code will do what I need

1. Copy mask image over source
2. Make transparent all HotPink pixels

VB.NET:
        Dim g As Graphics
        Dim b_mask As New Bitmap(mask.Image)
        Dim b_original As New Bitmap(src.Image)
        g = Graphics.FromImage(b_original)
        g.DrawImage(b_mask, New Point(0, 0))
        b_original.MakeTransparent(Color.HotPink)
        src.Image = b_original

This works fine, but what if there are some HotPink pixels on the original before applying the mask?
Solution could be to shift the mask pixel color using ColorMatrix and ImageAttributes, but how to be sure that new pixel color doesn't exist on original image?

Of course, looping through pixels is not what I want to do because of speed issue.
 

Latest posts

Back
Top