X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=render%2Fimage.c;h=0ab213747acd4a6c105e90ce9635732b8ca96e26;hb=90cecafa3de2f118e550622932d1d30266c71226;hp=f6d70ee9a4ee9db62840a3b994340cee680aaebb;hpb=4b5373f609e6462995a38cc4f0f50b17cbc8f835;p=chaz%2Fopenbox diff --git a/render/image.c b/render/image.c index f6d70ee9..0ab21374 100644 --- a/render/image.c +++ b/render/image.c @@ -124,6 +124,12 @@ static RrImagePic* ResizeImage(RrPixel32 *src, gulong ratioX, ratioY; 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 */ aspectW = dstW; aspectH = (gint)(dstW * ((gdouble)srcH / srcW)); @@ -131,11 +137,11 @@ static RrImagePic* ResizeImage(RrPixel32 *src, aspectH = dstH; aspectW = (gint)(dstH * ((gdouble)srcW / srcH)); } - dstW = aspectW; - dstH = aspectH; + dstW = aspectW ? aspectW : 1; + dstH = aspectH ? aspectH : 1; if (srcW == dstW && srcH == dstH) - return NULL; /* no scaling needed ! */ + return NULL; /* no scaling needed! */ dststart = dst = g_new(RrPixel32, dstW * dstH); @@ -294,6 +300,7 @@ void RrImageDrawRGBA(RrPixel32 *target, RrTextureRGBA *rgba, DrawRGBA(target, target_w, target_h, scaled->data, scaled->width, scaled->height, rgba->alpha, area); + RrImagePicFree(scaled); } else DrawRGBA(target, target_w, target_h,