(self, gc, x, y, im, transform=None)
| 639 | return not mpl.rcParams['image.composite_image'] |
| 640 | |
| 641 | def draw_image(self, gc, x, y, im, transform=None): |
| 642 | # docstring inherited |
| 643 | |
| 644 | h, w = im.shape[:2] |
| 645 | if w == 0 or h == 0: |
| 646 | return |
| 647 | |
| 648 | if not os.path.exists(getattr(self.fh, "name", "")): |
| 649 | raise ValueError( |
| 650 | "streamed pgf-code does not support raster graphics, consider " |
| 651 | "using the pgf-to-pdf option") |
| 652 | |
| 653 | # save the images to png files |
| 654 | path = pathlib.Path(self.fh.name) |
| 655 | fname_img = "%s-img%d.png" % (path.stem, self.image_counter) |
| 656 | Image.fromarray(im[::-1]).save(path.parent / fname_img) |
| 657 | self.image_counter += 1 |
| 658 | |
| 659 | # reference the image in the pgf picture |
| 660 | _writeln(self.fh, r"\begin{pgfscope}") |
| 661 | self._print_pgf_clip(gc) |
| 662 | f = 1. / self.dpi # from display coords to inch |
| 663 | if transform is None: |
| 664 | _writeln(self.fh, |
| 665 | r"\pgfsys@transformshift{%fin}{%fin}" % (x * f, y * f)) |
| 666 | w, h = w * f, h * f |
| 667 | else: |
| 668 | tr1, tr2, tr3, tr4, tr5, tr6 = transform.frozen().to_values() |
| 669 | _writeln(self.fh, |
| 670 | r"\pgfsys@transformcm{%f}{%f}{%f}{%f}{%fin}{%fin}" % |
| 671 | (tr1 * f, tr2 * f, tr3 * f, tr4 * f, |
| 672 | (tr5 + x) * f, (tr6 + y) * f)) |
| 673 | w = h = 1 # scale is already included in the transform |
| 674 | interp = str(transform is None).lower() # interpolation in PDF reader |
| 675 | _writeln(self.fh, |
| 676 | r"\pgftext[left,bottom]" |
| 677 | r"{%s[interpolate=%s,width=%fin,height=%fin]{%s}}" % |
| 678 | (_get_image_inclusion_command(), |
| 679 | interp, w, h, fname_img)) |
| 680 | _writeln(self.fh, r"\end{pgfscope}") |
| 681 | |
| 682 | def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None): |
| 683 | # docstring inherited |
nothing calls this directly
no test coverage detected