diff options
Diffstat (limited to 'image.c')
-rw-r--r-- | image.c | 48 |
1 files changed, 46 insertions, 2 deletions
@@ -33,8 +33,10 @@ void img_init(img_t *img, win_t *win) { zoom_min = zoom_levels[0] / 100.0; zoom_max = zoom_levels[zl_cnt - 1] / 100.0; - if (img) + if (img) { img->zoom = 1.0; + img->aa = 1; + } if (win) { imlib_context_set_display(win->env.dpy); @@ -63,6 +65,7 @@ int img_load(img_t *img, const char *filename) { } imlib_context_set_image(im); + imlib_context_set_anti_alias(img->aa); img->re = 0; img->checkpan = 0; @@ -104,7 +107,7 @@ void img_render(img_t *img, win_t *win) { if (!img || !win || !imlib_context_get_image()) return; - if ((!img->re || !img->zoomed) && SCALE_MODE != SCALE_ZOOM) { + if (!img->zoomed && SCALE_MODE != SCALE_ZOOM) { /* set zoom level to fit image into window */ zw = (float) win->w / (float) img->w; zh = (float) win->h / (float) img->h; @@ -241,3 +244,44 @@ int img_pan(img_t *img, win_t *win, pandir_t dir) { return ox != img->x || oy != img->y; } + +int img_rotate(img_t *img, win_t *win, int d) { + int ox, oy, tmp; + + if (!img || !win) + return 0; + + ox = d == 1 ? img->x : win->w - img->x - img->w * img->zoom; + oy = d == 3 ? img->y : win->h - img->y - img->h * img->zoom; + + imlib_image_orientate(d); + + img->x = oy + (win->w - win->h) / 2; + img->y = ox + (win->h - win->w) / 2; + + tmp = img->w; + img->w = img->h; + img->h = tmp; + + img->checkpan = 1; + + return 1; +} + +int img_rotate_left(img_t *img, win_t *win) { + return img_rotate(img, win, 3); +} + +int img_rotate_right(img_t *img, win_t *win) { + return img_rotate(img, win, 1); +} + +int img_toggle_antialias(img_t *img) { + if (!img) + return 0; + + img->aa ^= 1; + imlib_context_set_anti_alias(img->aa); + + return 1; +} |