MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / pixel

Method pixel

src/__init__.py:13791–13807  ·  view source on GitHub ↗

Get color tuple of pixel (x, y). Last item is the alpha if Pixmap.alpha is true.

(self, x, y)

Source from the content-addressed store, hash-verified

13789 return bytes_out.getvalue()
13790
13791 def pixel(self, x, y):
13792 """Get color tuple of pixel (x, y).
13793 Last item is the alpha if Pixmap.alpha is true."""
13794 if g_use_extra:
13795 return extra.pixmap_pixel(self.this.m_internal, x, y)
13796 if (0
13797 or x < 0
13798 or x >= self.this.m_internal.w
13799 or y < 0
13800 or y >= self.this.m_internal.h
13801 ):
13802 RAISEPY(MSG_PIXEL_OUTSIDE, PyExc_ValueError)
13803 n = self.this.m_internal.n
13804 stride = self.this.m_internal.stride
13805 i = stride * y + n * x
13806 ret = tuple( self.samples_mv[ i: i+n])
13807 return ret
13808
13809 @property
13810 def samples(self)->bytes:

Callers 3

test_memoryviewFunction · 0.95
test_3050Function · 0.80
average_colorFunction · 0.80

Calls 1

RAISEPYFunction · 0.85

Tested by 3

test_memoryviewFunction · 0.76
test_3050Function · 0.64
average_colorFunction · 0.64