From ae7d739a0b93f4b899809ed24dead866d9fd7632 Mon Sep 17 00:00:00 2001 From: geisserml Date: Mon, 27 Mar 2023 21:10:40 +0200 Subject: [PATCH] bitmap: slightly improve docs --- src/pypdfium2/_helpers/bitmap.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pypdfium2/_helpers/bitmap.py b/src/pypdfium2/_helpers/bitmap.py index 7582690eb..58ae968df 100644 --- a/src/pypdfium2/_helpers/bitmap.py +++ b/src/pypdfium2/_helpers/bitmap.py @@ -206,7 +206,8 @@ def to_numpy(self): Each row contains as many pixels as the bitmap is wide. The length of each pixel corresponds to the number of channels. - The resulting array is supposed to share memory with the original bitmap buffer, so changes to the buffer should be reflected in the array, and vice versa. + The resulting array is supposed to share memory with the original bitmap buffer, + so changes to the buffer should be reflected in the array, and vice versa. Returns: numpy.ndarray: NumPy array (representation of the bitmap buffer). @@ -230,7 +231,10 @@ def to_pil(self): """ Convert the bitmap to a :mod:`PIL` image, using :func:`PIL.Image.frombuffer`. - For ``RGBA``, ``RGBX`` and ``L`` buffers, PIL is supposed to share memory with the original bitmap buffer, so changes to the buffer should be reflected in the image. Otherwise, PIL will make a copy of the data. + For ``RGBA``, ``RGBX`` and ``L`` buffers, PIL is supposed to share memory with + the original bitmap buffer, so changes to the buffer should be reflected in the image + (however, changes to the image may not be reflected in the buffer due to PIL's behaviour). + Otherwise, PIL will make a copy of the data. Returns: PIL.Image.Image: PIL image (representation or copy of the bitmap buffer). @@ -257,7 +261,8 @@ def to_pil(self): def from_pil(cls, pil_image): """ Convert a :mod:`PIL` image to a PDFium bitmap. - Due to the restricted number of color formats and bit depths supported by PDFium's bitmap implementation, this may be a lossy operation. + Due to the restricted number of color formats and bit depths supported by PDFium's + bitmap implementation, this may be a lossy operation. Returns: PdfBitmap: PDFium bitmap (with a copy of the PIL image's data).