From f4cdca88003c57cf39aa06a961208d352c00b203 Mon Sep 17 00:00:00 2001 From: Julian Smith Date: Tue, 26 Sep 2023 17:39:36 +0100 Subject: [PATCH] Added test_2692() and fix rebase implementation. Changed `fz_identity` to `mupdf.FzMatrix()` and use `mupdf.FzCookie()` instead of `None. --- src/__init__.py | 8 ++++---- tests/test_general.py | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/__init__.py b/src/__init__.py index 5fd1e7710..9ce793b8d 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -13723,9 +13723,9 @@ def JM_pixmap_from_page(doc, page, ctm, cs, alpha, annots, clip): dev = mupdf.fz_new_draw_device(matrix, pix) if annots: - mupdf.fz_run_page(page, dev, fz_identity, NULL); + mupdf.fz_run_page(page, dev, mupdf.FzMatrix(), NULL); else: - fz_run_page_contents(ctx, page, dev, fz_identity, mupdf.FzCookie()) + fz_run_page_contents(ctx, page, dev, mupdf.FzMatrix(), mupdf.FzCookie()) mupdf.fz_close_device(dev) return pix @@ -16236,7 +16236,7 @@ def JM_pixmap_from_display_list( if not mupdf.fz_is_infinite_rect(rclip): dev = mupdf.fz_new_draw_device_with_bbox(matrix, pix, irect) - mupdf.fz_run_display_list(list_, dev, fz_identity, rclip, None) + mupdf.fz_run_display_list(list_, dev, mupdf.FzMatrix(), rclip, mupdf.FzCookie()) else: dev = mupdf.fz_new_draw_device(matrix, pix) mupdf.fz_run_display_list(list_, dev, mupdf.FzMatrix(), mupdf.FzRect(mupdf.FzRect.Fixed_INFINITE), mupdf.FzCookie()) @@ -20518,7 +20518,7 @@ def _derotate_matrix(page): if isinstance(page, mupdf.PdfPage): return JM_py_from_matrix(JM_derotate_page_matrix(page)) else: - return JM_py_from_matrix(fz_identity) + return JM_py_from_matrix(mupdf.FzMatrix()) @staticmethod def _fill_widget(annot, widget): diff --git a/tests/test_general.py b/tests/test_general.py index b1409dd74..797ce64bf 100644 --- a/tests/test_general.py +++ b/tests/test_general.py @@ -511,3 +511,15 @@ def test_2430(): font = fitz.Font("helv") for i in range(1000): _ = font.flags + +def test_2692(): + document = fitz.Document(f'{scriptdir}/resources/2.pdf') + for page in document: + pix = pix = page.get_pixmap(clip=fitz.Rect(0,0,10,10)) + dl = page.get_displaylist(annots=True) + pix = dl.get_pixmap( + matrix=fitz.Identity, + colorspace=fitz.csRGB, + alpha=False, + clip=fitz.Rect(0,0,10,10), + )