This is an example of a quick transparency code

02-02-2002, 11:51 PM
I was trying to work out how to do an easy way of transparency instead of using all that code from the bitblt which was a page i made my own in like 3-4 lines

its attached

02-03-2002, 09:20 AM
A good idea. Nicely done. :)

But what if I'm using a large image... it might take a while....

Garrett Sever
02-03-2002, 10:42 AM
That's exactly the problem with what young andrew has done here.

The Point/PSet (or GetPixel/SetPixel for API) method has been around for quite some time, but it IS hideously slow for larger bitmaps. Try something 300x300 and watch it lag.

The easiest way of accomplishing transparency AND speed is to use two bitmaps for the mask and the picture. I generally use this one. You end up with bigger resource files, but... it'll work 99.99999% of the time.
Another way (and the most complicated) would be to create a monochrome bitmap, use GetBitmapBits to get the individual Bytes of your image. As you loop thru the bits in your pixel array, you create another array of the monochrome bits. You then set the mask pixels by using SetBitmapBits. This puts you in exactly the same place as the first bullet.
Finally would be to use the BitBlt methods to create a mask from the image by setting the back color = transparency color and blting it onto a monochrome bitmap. Unfortunately this doesn't work really well on 95 systems (98 and ME seemed to work well).

02-08-2002, 12:33 PM
but, if you use two bitmaps instead, why don't you make the mask into a gif file, so that it is much smaller in file size, won't that decrease resources used? I was also thinking that since I am making an RPG, but there is only one hero, then could I make a gif image, that is already a mask for the tileset of the character, so that I don't have to use Get/Set pixel?

02-08-2002, 05:41 PM
I tried that a few days ago. For some reason bitblt copied across the transparent pixles as well, eliminating the background.

Check out my solution here

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum