When icons had a very small aspect ratio, we crashed, don't.
This commit is contained in:
parent
0e92465751
commit
d47d5a2801
1 changed files with 9 additions and 3 deletions
|
@ -124,6 +124,12 @@ static RrImagePic* ResizeImage(RrPixel32 *src,
|
||||||
gulong ratioX, ratioY;
|
gulong ratioX, ratioY;
|
||||||
gulong aspectW, aspectH;
|
gulong aspectW, aspectH;
|
||||||
|
|
||||||
|
/* XXX should these variables be ensured to not be zero in the callers? */
|
||||||
|
srcW = srcW ? srcW : 1;
|
||||||
|
srcH = srcH ? srcH : 1;
|
||||||
|
dstW = dstW ? dstW : 1;
|
||||||
|
dstH = dstH ? dstH : 1;
|
||||||
|
|
||||||
/* keep the aspect ratio */
|
/* keep the aspect ratio */
|
||||||
aspectW = dstW;
|
aspectW = dstW;
|
||||||
aspectH = (gint)(dstW * ((gdouble)srcH / srcW));
|
aspectH = (gint)(dstW * ((gdouble)srcH / srcW));
|
||||||
|
@ -131,11 +137,11 @@ static RrImagePic* ResizeImage(RrPixel32 *src,
|
||||||
aspectH = dstH;
|
aspectH = dstH;
|
||||||
aspectW = (gint)(dstH * ((gdouble)srcW / srcH));
|
aspectW = (gint)(dstH * ((gdouble)srcW / srcH));
|
||||||
}
|
}
|
||||||
dstW = aspectW;
|
dstW = aspectW ? aspectW : 1;
|
||||||
dstH = aspectH;
|
dstH = aspectH ? aspectH : 1;
|
||||||
|
|
||||||
if (srcW == dstW && srcH == dstH)
|
if (srcW == dstW && srcH == dstH)
|
||||||
return NULL; /* no scaling needed ! */
|
return NULL; /* no scaling needed! */
|
||||||
|
|
||||||
dststart = dst = g_new(RrPixel32, dstW * dstH);
|
dststart = dst = g_new(RrPixel32, dstW * dstH);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue