mirror of https://github.com/OpenTTD/OpenTTD
(svn r13640) -Codechange: make colours behind not fully solid objects less darker for BM_TRANSPARENT (for 32bpp blitters)
parent
114c820c56
commit
1834a2f670
|
@ -136,15 +136,24 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
|
||||||
* we produce a result the newgrf maker didn't expect ;) */
|
* 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 */
|
/* Make the current color a bit more black, so it looks like this image is transparent */
|
||||||
src_px += n;
|
|
||||||
src_n += n;
|
src_n += n;
|
||||||
|
if (src_px->a == 255) {
|
||||||
do {
|
src_px += n;
|
||||||
*dst = MakeTransparent(*dst, 192);
|
do {
|
||||||
*anim = remap[*anim];
|
*dst = MakeTransparent(*dst, 3, 4);
|
||||||
anim++;
|
*anim = remap[*anim];
|
||||||
dst++;
|
anim++;
|
||||||
} while (--n != 0);
|
dst++;
|
||||||
|
} while (--n != 0);
|
||||||
|
} else {
|
||||||
|
do {
|
||||||
|
*dst = MakeTransparent(*dst, (256 * 4 - src_px->a), 256 * 4);
|
||||||
|
*anim = remap[*anim];
|
||||||
|
anim++;
|
||||||
|
dst++;
|
||||||
|
src_px++;
|
||||||
|
} while (--n != 0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -105,16 +105,17 @@ public:
|
||||||
/**
|
/**
|
||||||
* Make a pixel looks like it is transparent.
|
* Make a pixel looks like it is transparent.
|
||||||
* @param colour the colour already on the screen.
|
* @param colour the colour already on the screen.
|
||||||
* @param amount the amount of transparency, times 256.
|
* @param nom the amount of transparency, nominator, makes colour lighter.
|
||||||
|
* @param denom denominator, makes colour darker.
|
||||||
* @return the new colour for the screen.
|
* @return the new colour for the screen.
|
||||||
*/
|
*/
|
||||||
static inline uint32 MakeTransparent(uint32 colour, uint amount)
|
static inline uint32 MakeTransparent(uint32 colour, uint nom, uint denom = 256)
|
||||||
{
|
{
|
||||||
uint r = GB(colour, 16, 8);
|
uint r = GB(colour, 16, 8);
|
||||||
uint g = GB(colour, 8, 8);
|
uint g = GB(colour, 8, 8);
|
||||||
uint b = GB(colour, 0, 8);
|
uint b = GB(colour, 0, 8);
|
||||||
|
|
||||||
return ComposeColour(0xFF, r * amount / 256, g * amount / 256, b * amount / 256);
|
return ComposeColour(0xFF, r * nom / denom, g * nom / denom, b * nom / denom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -142,13 +142,20 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
|
||||||
* we produce a result the newgrf maker didn't expect ;) */
|
* 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 */
|
/* Make the current color a bit more black, so it looks like this image is transparent */
|
||||||
src_px += n;
|
|
||||||
src_n += n;
|
src_n += n;
|
||||||
|
if (src_px->a == 255) {
|
||||||
do {
|
src_px += n;
|
||||||
*dst = MakeTransparent(*dst, 192);
|
do {
|
||||||
dst++;
|
*dst = MakeTransparent(*dst, 3, 4);
|
||||||
} while (--n != 0);
|
dst++;
|
||||||
|
} while (--n != 0);
|
||||||
|
} else {
|
||||||
|
do {
|
||||||
|
*dst = MakeTransparent(*dst, (256 * 4 - src_px->a), 256 * 4);
|
||||||
|
dst++;
|
||||||
|
src_px++;
|
||||||
|
} while (--n != 0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue