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

Method draw_image

lib/matplotlib/backends/backend_ps.py:580–610  ·  view source on GitHub ↗
(self, gc, x, y, im, transform=None)

Source from the content-addressed store, hash-verified

578
579 @_log_if_debug_on
580 def draw_image(self, gc, x, y, im, transform=None):
581 # docstring inherited
582
583 h, w = im.shape[:2]
584 imagecmd = "false 3 colorimage"
585 data = im[::-1, :, :3] # Vertically flipped rgb values.
586 hexdata = data.tobytes().hex("\n", -64) # Linewrap to 128 chars.
587
588 if transform is None:
589 matrix = "1 0 0 1 0 0"
590 xscale = w / self.image_magnification
591 yscale = h / self.image_magnification
592 else:
593 matrix = " ".join(map(str, transform.frozen().to_values()))
594 xscale = 1.0
595 yscale = 1.0
596
597 self._pswriter.write(f"""\
598gsave
599{self._get_clip_cmd(gc)}
600{x:g} {y:g} translate
601[{matrix}] concat
602{xscale:g} {yscale:g} scale
603/DataString {w:d} string def
604{w:d} {h:d} 8 [ {w:d} 0 0 -{h:d} 0 {h:d} ]
605{{
606currentfile DataString readhexstring pop
607}} bind {imagecmd}
608{hexdata}
609grestore
610""")
611
612 @_log_if_debug_on
613 def draw_path(self, gc, path, transform, rgbFace=None):

Callers 2

stop_rasterizingMethod · 0.45
stop_filterMethod · 0.45

Calls 5

_get_clip_cmdMethod · 0.95
joinMethod · 0.80
to_valuesMethod · 0.80
frozenMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected