Rotated image transparency fix; re-scale max size fix
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1493 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -477,11 +477,12 @@ TFB_DrawCanvas_Rescale_Nearest (TFB_Canvas src_canvas, TFB_Canvas dest_canvas, E
|
||||
SDL_Surface *src = (SDL_Surface *)src_canvas;
|
||||
SDL_Surface *dst = (SDL_Surface *)dest_canvas;
|
||||
int x, y, sx, sy, *csax, *csay, csx, csy;
|
||||
int sax[321], say[241];
|
||||
int saspace[602];
|
||||
int *sax, *say;
|
||||
|
||||
if (size.width > 320 || size.height > 240)
|
||||
if (size.width + size.height > 600)
|
||||
{
|
||||
fprintf (stderr, "TFB_DrawCanvas_Scale: Tried to zoom an image to be larger than the screen! Failing.\n");
|
||||
fprintf (stderr, "TFB_DrawCanvas_Scale: Tried to zoom an image to unreasonable size! Failing.\n");
|
||||
return;
|
||||
}
|
||||
if (size.width > dst->w || size.height > dst->h)
|
||||
@@ -494,6 +495,8 @@ TFB_DrawCanvas_Rescale_Nearest (TFB_Canvas src_canvas, TFB_Canvas dest_canvas, E
|
||||
sx = (int) (65536.0 * (float) src->w / (float) size.width);
|
||||
sy = (int) (65536.0 * (float) src->h / (float) size.height);
|
||||
|
||||
sax = saspace;
|
||||
say = saspace + size.width + 1;
|
||||
/*
|
||||
* Precalculate row increments
|
||||
*/
|
||||
@@ -1004,6 +1007,7 @@ TFB_DrawCanvas_Rotate (TFB_Canvas src_canvas, TFB_Canvas dst_canvas, int angle,
|
||||
SDL_Surface *src = (SDL_Surface *)src_canvas;
|
||||
SDL_Surface *dst = (SDL_Surface *)dst_canvas;
|
||||
int ret;
|
||||
int r, g, b;
|
||||
|
||||
if (size.width > dst->w || size.height > dst->h)
|
||||
{
|
||||
@@ -1012,6 +1016,13 @@ TFB_DrawCanvas_Rotate (TFB_Canvas src_canvas, TFB_Canvas dst_canvas, int angle,
|
||||
return;
|
||||
}
|
||||
|
||||
if (TFB_DrawCanvas_GetTransparentColor (src, &r, &g, &b))
|
||||
{
|
||||
TFB_DrawCanvas_SetTransparentColor (dst, r, g, b, FALSE);
|
||||
/* fill destination with transparent color before rotating */
|
||||
SDL_FillRect(dst, NULL, SDL_MapRGB(dst->format, r, g, b));
|
||||
}
|
||||
|
||||
ret = rotateSurface (src, dst, angle, 0);
|
||||
if (ret != 0)
|
||||
{
|
||||
|
||||
@@ -330,11 +330,14 @@ TFB_DrawImage_New_Rotated (TFB_Image *img, int angle)
|
||||
{
|
||||
TFB_Canvas dst;
|
||||
EXTENT size;
|
||||
TFB_Image* newimg;
|
||||
int r, g, b;
|
||||
|
||||
/* sanity check */
|
||||
if (!img->NormalImg)
|
||||
{
|
||||
fprintf (stderr, "TFB_DrawImage_New_Rotated: source canvas is NULL! Failing.\n");
|
||||
fprintf (stderr, "TFB_DrawImage_New_Rotated: "
|
||||
"source canvas is NULL! Failing.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -342,12 +345,21 @@ TFB_DrawImage_New_Rotated (TFB_Image *img, int angle)
|
||||
dst = TFB_DrawCanvas_New_RotationTarget (img->NormalImg, angle);
|
||||
if (!dst)
|
||||
{
|
||||
fprintf (stderr, "TFB_DrawImage_New_Rotated: rotation target canvas not created! Failing.\n");
|
||||
fprintf (stderr, "TFB_DrawImage_New_Rotated: "
|
||||
"rotation target canvas not created! Failing.\n");
|
||||
return NULL;
|
||||
}
|
||||
TFB_DrawCanvas_Rotate (img->NormalImg, dst, angle, size);
|
||||
|
||||
newimg = TFB_DrawImage_New (dst);
|
||||
if (newimg && TFB_DrawCanvas_GetTransparentColor (
|
||||
newimg->NormalImg, &r, &g, &b))
|
||||
{ /* reset colorkey info to clear potential SRCALPHA */
|
||||
TFB_DrawCanvas_SetTransparentColor (newimg->NormalImg,
|
||||
r, g, b, FALSE);
|
||||
}
|
||||
|
||||
return TFB_DrawImage_New (dst);
|
||||
return newimg;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user