diff options
-rw-r--r-- | src/blitter/32bpp_anim.cpp | 4 | ||||
-rw-r--r-- | src/blitter/32bpp_base.hpp | 30 | ||||
-rw-r--r-- | src/blitter/32bpp_simple.cpp | 4 |
3 files changed, 23 insertions, 15 deletions
diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp index 9dbc19fba..7f8fe7651 100644 --- a/src/blitter/32bpp_anim.cpp +++ b/src/blitter/32bpp_anim.cpp @@ -59,7 +59,7 @@ void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL /* Make the current color a bit more black, so it looks like this image is transparent */ if (src->a != 0) { - *dst = MakeTransparent(*dst, 75); + *dst = MakeTransparent(*dst, 192); *anim = bp->remap[*anim]; } break; @@ -90,7 +90,7 @@ void Blitter_32bppAnim::DrawColorMappingRect(void *dst, int width, int height, i if (pal == PALETTE_TO_TRANSPARENT) { do { for (int i = 0; i != width; i++) { - *udst = MakeTransparent(*udst, 60); + *udst = MakeTransparent(*udst, 154); *anim = 0; udst++; anim++; diff --git a/src/blitter/32bpp_base.hpp b/src/blitter/32bpp_base.hpp index 3fce0951a..51afea336 100644 --- a/src/blitter/32bpp_base.hpp +++ b/src/blitter/32bpp_base.hpp @@ -48,15 +48,19 @@ public: */ static inline uint ComposeColourRGBA(uint r, uint g, uint b, uint a, uint current) { + if (a == 0) return current; + if (a >= 255) return ComposeColour(0xFF, r, g, b); + uint cr, cg, cb; cr = GB(current, 16, 8); cg = GB(current, 8, 8); cb = GB(current, 0, 8); + /* The 256 is wrong, it should be 255, but 256 is much faster... */ return ComposeColour(0xFF, - (r * a + cr * (255 - a)) / 255, - (g * a + cg * (255 - a)) / 255, - (b * a + cb * (255 - a)) / 255); + (r * a + cr * (256 - a)) / 256, + (g * a + cg * (256 - a)) / 256, + (b * a + cb * (256 - a)) / 256); } /** @@ -64,24 +68,28 @@ public: */ static inline uint ComposeColourPA(uint colour, uint a, uint current) { + if (a == 0) return current; + if (a >= 255) return (colour | 0xFF000000); + uint r, g, b, cr, cg, cb; - r = GB(colour, 16, 8); - g = GB(colour, 8, 8); - b = GB(colour, 0, 8); + r = GB(colour, 16, 8); + g = GB(colour, 8, 8); + b = GB(colour, 0, 8); cr = GB(current, 16, 8); cg = GB(current, 8, 8); cb = GB(current, 0, 8); + /* The 256 is wrong, it should be 255, but 256 is much faster... */ return ComposeColour(0xFF, - (r * a + cr * (255 - a)) / 255, - (g * a + cg * (255 - a)) / 255, - (b * a + cb * (255 - a)) / 255); + (r * a + cr * (256 - a)) / 256, + (g * a + cg * (256 - a)) / 256, + (b * a + cb * (256 - a)) / 256); } /** * Make a pixel looks like it is transparent. * @param colour the colour already on the screen. - * @param amount the amount of transparency, times 100. + * @param amount the amount of transparency, times 256. * @return the new colour for the screen. */ static inline uint MakeTransparent(uint colour, uint amount) @@ -91,7 +99,7 @@ public: g = GB(colour, 8, 8); b = GB(colour, 0, 8); - return ComposeColour(0xFF, r * amount / 100, g * amount / 100, b * amount / 100); + return ComposeColour(0xFF, r * amount / 256, g * amount / 256, b * amount / 256); } /** diff --git a/src/blitter/32bpp_simple.cpp b/src/blitter/32bpp_simple.cpp index 6dbdd2267..b5afea9eb 100644 --- a/src/blitter/32bpp_simple.cpp +++ b/src/blitter/32bpp_simple.cpp @@ -40,7 +40,7 @@ void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoo * we produce a result the newgrf maker didn't expect ;) */ /* Make the current color a bit more black, so it looks like this image is transparent */ - if (src->a != 0) *dst = MakeTransparent(*dst, 75); + if (src->a != 0) *dst = MakeTransparent(*dst, 192); break; default: @@ -60,7 +60,7 @@ void Blitter_32bppSimple::DrawColorMappingRect(void *dst, int width, int height, if (pal == PALETTE_TO_TRANSPARENT) { do { for (int i = 0; i != width; i++) { - *udst = MakeTransparent(*udst, 60); + *udst = MakeTransparent(*udst, 154); udst++; } udst = udst - width + _screen.pitch; |