Fixed bug 1822 - Inconsistent renderer behaviour on rotation Sylvain 2016-11-07 08:49:34 UTC when rotated +90 or -90, some transparent lines appears, though there is no Alpha or ColorKey. if you set a dummy colorkey, it will remove the line ... if you set a some alpha mod, the +90/-90 get transparent but not the 0/180 ...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c
index 0141d17..29168a9 100644
--- a/src/render/software/SDL_rotate.c
+++ b/src/render/software/SDL_rotate.c
@@ -417,7 +417,7 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
SDL_Surface *rz_dst;
int is32bit, angle90;
int i;
- Uint8 r = 0, g = 0, b = 0;
+ Uint8 r = 0, g = 0, b = 0, a = 0;
Uint32 colorkey = 0;
int colorKeyAvailable = 0;
double sangleinv, cangleinv;
@@ -428,12 +428,12 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
if (src == NULL)
return (NULL);
- if (src->flags & SDL_TRUE/* SDL_SRCCOLORKEY */)
- {
+ if (src->flags & SDL_TRUE/* SDL_SRCCOLORKEY */) {
colorkey = _colorkey(src);
- SDL_GetRGB(colorkey, src->format, &r, &g, &b);
+ SDL_GetRGBA(colorkey, src->format, &r, &g, &b, &a);
colorKeyAvailable = 1;
}
+
/*
* Determine if source surface is 32bit or 8bit
*/
@@ -485,10 +485,10 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
/* Adjust for guard rows */
rz_dst->h = dstheight;
- if (colorKeyAvailable == 1){
- colorkey = SDL_MapRGB(rz_dst->format, r, g, b);
+ if (colorKeyAvailable == 1) {
+ colorkey = SDL_MapRGBA(rz_dst->format, r, g, b, a);
- SDL_FillRect(rz_dst, NULL, colorkey );
+ SDL_FillRect(rz_dst, NULL, colorkey);
}
/*
@@ -523,10 +523,9 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
_transformSurfaceRGBA(rz_src, rz_dst, centerx, centery, (int) (sangleinv), (int) (cangleinv), flipx, flipy, smooth);
}
/*
- * Turn on source-alpha support
- */
+ * Turn on source-alpha support
+ */
/* SDL_SetAlpha(rz_dst, SDL_SRCALPHA, 255); */
- SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src));
} else {
/*
* Copy palette and colorkey info
@@ -543,7 +542,12 @@ SDLgfx_rotateSurface(SDL_Surface * src, double angle, int centerx, int centery,
} else {
transformSurfaceY(rz_src, rz_dst, centerx, centery, (int)(sangleinv), (int)(cangleinv), flipx, flipy);
}
- SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, _colorkey(rz_src));
+ }
+
+ if (colorKeyAvailable == 1) {
+ SDL_SetColorKey(rz_dst, /* SDL_SRCCOLORKEY */ SDL_TRUE | SDL_RLEACCEL, colorkey);
+ } else {
+ SDL_SetColorKey(rz_dst, SDL_FALSE, 0);
}
/* copy alpha mod, color mod, and blend mode */