From 3d622d60cf7c6c609cfc48b774ee0d8aef2d1d85 Mon Sep 17 00:00:00 2001 From: homm Date: Thu, 2 Jun 2016 23:47:45 +0300 Subject: [PATCH] make perspecive transform arguments order more common --- PIL/Image.py | 4 +--- libImaging/Geometry.c | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/PIL/Image.py b/PIL/Image.py index 5bac01665..a6fd4e95d 100644 --- a/PIL/Image.py +++ b/PIL/Image.py @@ -1881,9 +1881,7 @@ class Image(object): elif method == PERSPECTIVE: # change argument order to match implementation - data = (data[2], data[0], data[1], - data[5], data[3], data[4], - data[6], data[7]) + data = data[0:8] elif method == QUAD: # quadrilateral warp. data specifies the four corners diff --git a/libImaging/Geometry.c b/libImaging/Geometry.c index e09eef62e..103b75e53 100644 --- a/libImaging/Geometry.c +++ b/libImaging/Geometry.c @@ -264,8 +264,8 @@ perspective_transform(double* xin, double* yin, int x, int y, void* data) double a3 = a[3]; double a4 = a[4]; double a5 = a[5]; double a6 = a[6]; double a7 = a[7]; - xin[0] = (a0 + a1*x + a2*y) / (a6*x + a7*y + 1); - yin[0] = (a3 + a4*x + a5*y) / (a6*x + a7*y + 1); + xin[0] = (a0*x + a1*y + a2) / (a6*x + a7*y + 1); + yin[0] = (a3*x + a4*y + a5) / (a6*x + a7*y + 1); return 1; }