diff --git a/libs/arg.c b/libs/arg.c index 02851ef..9cff673 100644 --- a/libs/arg.c +++ b/libs/arg.c @@ -305,25 +305,7 @@ setimgsize(const Arg *arg) return; #endif - /* this makes sure we cannot scale down the image too much */ - if ((!image && imageheight + arg->i < imageheight) || hideimage) return; - - cleanupimage(); - - imageheight += arg->i; - imagewidth += arg->i; - - drawimage(); - - if (!image) { - imageheight -= arg->i; - imagewidth -= arg->i; - return; - } else { - drawimage(); - } - - drawmenu(); + setimagesize(imagewidth + arg->i, imageheight + arg->i); } void diff --git a/libs/img.c b/libs/img.c index c155fe6..09f7813 100644 --- a/libs/img.c +++ b/libs/img.c @@ -1,3 +1,35 @@ +void +setimagesize(int width, int height) +{ + #if !USEIMAGE + return; + #endif + + int oih = 0; + int oiw = 0; + + /* this makes sure we cannot scale down the image too much */ + if ((!image && height < imageheight) || (!image && width < imagewidth) || hideimage) return; + + cleanupimage(); + + oih = imageheight; + oiw = imagewidth; + + imageheight = height; + imagewidth = width; + + drawimage(); + + if (!image) { + imageheight = oih; + imagewidth = oiw; + return; + } + + drawmenu(); +} + void flipimage(void) { diff --git a/libs/img.h b/libs/img.h index d6b8ff5..14b545e 100644 --- a/libs/img.h +++ b/libs/img.h @@ -3,6 +3,7 @@ #include #include +static void setimagesize(int width, int height); static void setimageopts(void); static void cleanupimage(void); static void drawimage(void);