Skip to content

Commit

Permalink
bitmap: slightly improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Mar 27, 2023
1 parent 4bbae67 commit ae7d739
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/pypdfium2/_helpers/bitmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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).
Expand All @@ -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).
Expand Down

0 comments on commit ae7d739

Please sign in to comment.