diff options
author | Kim Woelders <kim@woelders.dk> | 2021-11-25 05:06:14 +0100 |
---|---|---|
committer | Kim Woelders <kim@woelders.dk> | 2021-11-25 15:45:56 +0100 |
commit | 6e27c1e2c3b75da0aca3ea696f9f5d677eb8a4cc (patch) | |
tree | 3fe4f17ca03f76a8beeaf2ee5aba63bd5607a85f | |
parent | add72b4023735f67bce5c1e01f1c2198914d1b52 (diff) | |
download | imlib2-6e27c1e2c3b75da0aca3ea696f9f5d677eb8a4cc.tar.gz |
Fix y-upscaling in imlib_create_scaled_image_from_drawable()
-rw-r--r-- | src/lib/x11_grab.c | 36 | ||||
-rw-r--r-- | test/test_grab.cpp | 6 |
2 files changed, 27 insertions, 15 deletions
diff --git a/src/lib/x11_grab.c b/src/lib/x11_grab.c index 01170c9..13e6110 100644 --- a/src/lib/x11_grab.c +++ b/src/lib/x11_grab.c @@ -846,12 +846,13 @@ __imlib_GrabDrawableScaledToRGBA(DATA32 * data, int nu_x_dst, int nu_y_dst, { int rc; int tmpmask = 0; - int i, xx; + int h_tmp, i, xx; XGCValues gcv; GC gc = 0, mgc = 0; Pixmap psc, msc; - psc = XCreatePixmap(d, p, w_dst, h_src, depth); + h_tmp = h_dst > h_src ? h_dst : h_src; + psc = XCreatePixmap(d, p, w_dst, h_tmp, depth); gcv.foreground = 0; gcv.subwindow_mode = IncludeInferiors; @@ -897,7 +898,7 @@ __imlib_GrabDrawableScaledToRGBA(DATA32 * data, int nu_x_dst, int nu_y_dst, { if (*pdomask) { - msc = XCreatePixmap(d, p, w_dst, h_src, 1); + msc = XCreatePixmap(d, p, w_dst, h_tmp, 1); if (!mgc) mgc = XCreateGC(d, msc, GCForeground | GCGraphicsExposures, &gcv); @@ -912,16 +913,33 @@ __imlib_GrabDrawableScaledToRGBA(DATA32 * data, int nu_x_dst, int nu_y_dst, if (msc != None) XCopyArea(d, m, msc, mgc, xx, 0, 1, h_src, i, 0); } - for (i = 0; i < h_dst; i++) + if (h_dst > h_src) { - xx = (h_src * i) / h_dst; - XCopyArea(d, psc, psc, gc, 0, xx, w_dst, 1, 0, i); - if (msc != None) - XCopyArea(d, msc, msc, mgc, 0, xx, w_dst, 1, 0, i); + for (i = h_dst - 1; i > 0; i--) + { + xx = (h_src * i) / h_dst; + if (xx == i) + continue; /* Don't copy onto self */ + XCopyArea(d, psc, psc, gc, 0, xx, w_dst, 1, 0, i); + if (msc != None) + XCopyArea(d, msc, msc, mgc, 0, xx, w_dst, 1, 0, i); + } + } + else + { + for (i = 0; i < h_dst; i++) + { + xx = (h_src * i) / h_dst; + if (xx == i) + continue; /* Don't copy onto self */ + XCopyArea(d, psc, psc, gc, 0, xx, w_dst, 1, 0, i); + if (msc != None) + XCopyArea(d, msc, msc, mgc, 0, xx, w_dst, 1, 0, i); + } } } - rc = __imlib_GrabDrawableToRGBA(data, 0, 0, w_dst, h_src, d, psc, msc, + rc = __imlib_GrabDrawableToRGBA(data, 0, 0, w_dst, h_dst, d, psc, msc, v, cm, depth, 0, 0, w_dst, h_dst, pdomask, grab); diff --git a/test/test_grab.cpp b/test/test_grab.cpp index 1c4280c..5d5121a 100644 --- a/test/test_grab.cpp +++ b/test/test_grab.cpp @@ -131,14 +131,8 @@ _test_grab_1(int w, int h, int x0, int y0) xs = xd.scale > 0 ? xd.scale * x0 : x0; ws = xd.scale > 0 ? xd.scale * w : w; -#if 0 - // FIXME - y scaling doesn't work ys = xd.scale > 0 ? xd.scale * y0 : y0; hs = xd.scale > 0 ? xd.scale * h : h; -#else - ys = y0; - hs = h; -#endif if (xd.scale == 0) im = imlib_create_image_from_drawable(None, x0, y0, w, h, 0); |