From a17ac192c043a6bce51e16cf7cd076087c78d9a9 Mon Sep 17 00:00:00 2001 From: Henrique Nakashima Date: Wed, 21 Mar 2018 13:51:35 +0000 Subject: Explain how CPDF_Page::GetDisplayMatrix() inverts y. Change-Id: Ia6e9fe790065d0bfd288d425c10d1dd9e0cf8c31 Reviewed-on: https://pdfium-review.googlesource.com/28850 Reviewed-by: dsinclair Commit-Queue: dsinclair --- core/fpdfapi/page/cpdf_page.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'core/fpdfapi/page/cpdf_page.cpp') diff --git a/core/fpdfapi/page/cpdf_page.cpp b/core/fpdfapi/page/cpdf_page.cpp index 0c8d63de71..6518d80aa3 100644 --- a/core/fpdfapi/page/cpdf_page.cpp +++ b/core/fpdfapi/page/cpdf_page.cpp @@ -133,6 +133,12 @@ CFX_Matrix CPDF_Page::GetDisplayMatrix(int xPos, float x2 = 0; float y2 = 0; iRotate %= 4; + // This code implicitly inverts the y-axis to account for page coordinates + // pointing up and bitmap coordinates pointing down. (x0, y0) is the base + // point, (x1, y1) is that point translated on y and (x2, y2) is the point + // translated on x. On iRotate = 0, y0 is (yPos + ySize) and the translation + // to get y1 is performed as negative. This results in the desired + // transformation. switch (iRotate) { case 0: x0 = xPos; -- cgit v1.2.3