(self, gc, x, y, im, transform=None)
| 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"""\ |
| 598 | gsave |
| 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 | {{ |
| 606 | currentfile DataString readhexstring pop |
| 607 | }} bind {imagecmd} |
| 608 | {hexdata} |
| 609 | grestore |
| 610 | """) |
| 611 | |
| 612 | @_log_if_debug_on |
| 613 | def draw_path(self, gc, path, transform, rgbFace=None): |
no test coverage detected