MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _unpack

Method _unpack

lib/matplotlib/backends/backend_pdf.py:1599–1620  ·  view source on GitHub ↗

Unpack image array *im* into ``(data, alpha)``, which have shape ``(height, width, 3)`` (RGB) or ``(height, width, 1)`` (grayscale or alpha), except that alpha is None if the image is fully opaque.

(self, im)

Source from the content-addressed store, hash-verified

1597 return name
1598
1599 def _unpack(self, im):
1600 """
1601 Unpack image array *im* into ``(data, alpha)``, which have shape
1602 ``(height, width, 3)`` (RGB) or ``(height, width, 1)`` (grayscale or
1603 alpha), except that alpha is None if the image is fully opaque.
1604 """
1605 im = im[::-1]
1606 if im.ndim == 2:
1607 return im, None
1608 else:
1609 rgb = im[:, :, :3]
1610 rgb = np.array(rgb, order='C')
1611 # PDF needs a separate alpha image
1612 if im.shape[2] == 4:
1613 alpha = im[:, :, 3][..., None]
1614 if np.all(alpha == 255):
1615 alpha = None
1616 else:
1617 alpha = np.array(alpha, order='C')
1618 else:
1619 alpha = None
1620 return rgb, alpha
1621
1622 def _writePng(self, img):
1623 """

Callers 1

writeImagesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected