move image size stuff to a separate function we can call on demand

This commit is contained in:
speedie 2023-03-08 17:50:58 +01:00
parent 345a8467e5
commit 6a83ac707e
3 changed files with 34 additions and 19 deletions

View file

@ -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

View file

@ -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)
{

View file

@ -3,6 +3,7 @@
#include <Imlib2.h>
#include <openssl/md5.h>
static void setimagesize(int width, int height);
static void setimageopts(void);
static void cleanupimage(void);
static void drawimage(void);