This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository legacy-imlib2.
View the commit online.
commit 58f2fcb4c7d4632f253a207a8ba7e7ac195b9dfe
Author: Kim Woelders <k...@woelders.dk>
AuthorDate: Sat Jun 10 19:56:03 2023 +0200
scaling: Correct scaling up
When scaling up it worked like there was a 1 pixel border right and
bottom.
This change may affect applications that rely on the old behavior.
Setting the environment variable IMLIB2_LEGACY_SCALING to any value will
make imlib2 use the old algorithm.
When using e16 with the new (default) algorithm a few themes have
incorrectly rendered elements (unintended window border fading, opaque
pager highligt frame, more?).
Hopefully this change should go mostly unnoticed but if it turns out it
causes grief the default will probably have to be changed back.
---
src/lib/scale.c | 37 ++++++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 13 deletions(-)
diff --git a/src/lib/scale.c b/src/lib/scale.c
index ac07b87..40c2b9c 100644
--- a/src/lib/scale.c
+++ b/src/lib/scale.c
@@ -23,11 +23,14 @@ struct _imlib_scale_info {
#define INV_YAP (256 - yapoints[dyy + y])
#define YAP (yapoints[dyy + y])
+/* Scaling correction (0: old mode, 1: new (correct) mode) */
+static signed char scale_corr = -1;
+
static int *
-__imlib_CalcPoints(int sw, int dw, int b1, int b2)
+__imlib_CalcPoints(int sw, int dw, int b1, int b2, int up)
{
int *p, i;
- int val, inc, rv = 0;
+ int val, inc, rv = 0, corr;
if (dw < 0)
{
@@ -59,8 +62,9 @@ __imlib_CalcPoints(int sw, int dw, int b1, int b2)
/* Center */
if (i < dw - b2)
{
+ corr = up && (dw - (b1 + b2) > 1) ? scale_corr : 0;
val = b1 << 16;
- inc = ((sw - (b1 + b2)) << 16) / (dw - (b1 + b2));
+ inc = ((sw - corr - (b1 + b2)) << 16) / (dw - corr - (b1 + b2));
for (; i < dw - b2; i++)
{
p[i] = val >> 16;
@@ -124,16 +128,17 @@ __imlib_CalcApoints(int s, int d, int b1, int b2, int up)
/* Center */
if (d > b1 + b2)
{
- int ss, dd;
+ int ss, dd, corr;
- ss = s - (b1 + b2);
- dd = d - (b1 + b2);
+ corr = (d - (b1 + b2) > 1) ? scale_corr : 0;
+ ss = s - (b1 + b2) - corr;
+ dd = d - (b1 + b2) - corr;
val = 0;
inc = (ss << 16) / dd;
for (; i < d - b2; i++)
{
p[i] = (val >> 8) - ((val >> 8) & 0xffffff00);
- if (((val >> 16) + b1) >= (s - 1))
+ if (!corr && ((val >> 16) + b1) >= (s - 1))
p[i] = 0;
val += inc;
}
@@ -208,6 +213,9 @@ __imlib_CalcScaleInfo(ImlibImage * im, int sw, int sh, int dw, int dh, bool aa)
ImlibScaleInfo *isi;
int scw, sch;
+ if (scale_corr < 0)
+ scale_corr = getenv("IMLIB2_LEGACY_SCALING") ? 0 : 1;
+
scw = dw * im->w / sw;
sch = dh * im->h / sh;
@@ -221,24 +229,27 @@ __imlib_CalcScaleInfo(ImlibImage * im, int sw, int sh, int dw, int dh, bool aa)
isi->xup_yup = (abs(dw) >= sw) + ((abs(dh) >= sh) << 1);
isi->xpoints = __imlib_CalcPoints(im->w, scw,
- im->border.left, im->border.right);
+ im->border.left, im->border.right,
+ isi->xup_yup & 1);
if (!isi->xpoints)
goto bail;
isi->ypoints = __imlib_CalcPoints(im->h, sch,
- im->border.top, im->border.bottom);
+ im->border.top, im->border.bottom,
+ isi->xup_yup & 2);
if (!isi->ypoints)
goto bail;
if (aa)
{
- isi->xapoints = __imlib_CalcApoints(im->w, scw, im->border.left,
- im->border.right, isi->xup_yup & 1);
+ isi->xapoints = __imlib_CalcApoints(im->w, scw,
+ im->border.left, im->border.right,
+ isi->xup_yup & 1);
if (!isi->xapoints)
goto bail;
- isi->yapoints = __imlib_CalcApoints(im->h, sch, im->border.top,
- im->border.bottom,
+ isi->yapoints = __imlib_CalcApoints(im->h, sch,
+ im->border.top, im->border.bottom,
isi->xup_yup & 2);
if (!isi->yapoints)
goto bail;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.