|
That seems to involve pixel mixing. It's not as simple as you think. You must first take out the piece of land (rect) to be covered by the bitmap to save it, then determine the color depth, then mix it, and draw it out. The alpha blending Blit is very similar.
Pseudo-ma:
RGB16bit 565 color depth
pixel_high = pixel&(1111100000011111) b // take the high bit
pixel_mid = pixel&(0000011111100000) b // take the median
pixel_low = pixel&(0000000000011111) b // take the lower bit
pixel_rect is similar
pixeled_high = pixel_high * alpha + pixel_rect_high (1-alpha)
pixeled_mid = pixel_mid * alpha + pixel_mid_high (1-alpha)
pixeled_low = pixel_low * alpha + pixel_low_high (1-alpha)
Finally, draw the pixeled soil.
Alpha is a parameter between 1, 0. Setting the size can change the transparency.
There are better algorithms, I ca n’t remember, you can go online to check
I wrote this algorithm down from the book. I have n’t actually used it yet. Do n’t blame me if you have a mistake.
But if you want to get a dynamic transparency effect, it will not work without mixing pixels! !! |
|