@@ -609,9 +609,20 @@ def _pgf_path_draw(self, stroke=True, fill=False):
609
609
actions .append ("fill" )
610
610
writeln (self .fh , r"\pgfusepath{%s}" % "," .join (actions ))
611
611
612
- def draw_image (self , gc , x , y , im ):
613
- # TODO: Almost no documentation for the behavior of this function.
614
- # Something missing?
612
+ def option_scale_image (self ):
613
+ """
614
+ pgf backend supports affine transform of image.
615
+ """
616
+ return True
617
+
618
+ def option_image_nocomposite (self ):
619
+ """
620
+ return whether to generate a composite image from multiple images on
621
+ a set of axes
622
+ """
623
+ return not rcParams ['image.composite_image' ]
624
+
625
+ def draw_image (self , gc , x , y , im , transform = None ):
615
626
h , w = im .shape [:2 ]
616
627
if w == 0 or h == 0 :
617
628
return
@@ -627,7 +638,22 @@ def draw_image(self, gc, x, y, im):
627
638
writeln (self .fh , r"\begin{pgfscope}" )
628
639
self ._print_pgf_clip (gc )
629
640
f = 1. / self .dpi # from display coords to inch
630
- writeln (self .fh , r"\pgftext[at=\pgfqpoint{%fin}{%fin},left,bottom]{\pgfimage[interpolate=true,width=%fin,height=%fin]{%s}}" % (x * f , y * f , w * f , h * f , fname_img ))
641
+ if transform is None :
642
+ writeln (self .fh ,
643
+ r"\pgfsys@transformshift{%fin}{%fin}" % (x * f , y * f ))
644
+ w , h = w * f , h * f
645
+ else :
646
+ tr1 , tr2 , tr3 , tr4 , tr5 , tr6 = transform .frozen ().to_values ()
647
+ writeln (self .fh ,
648
+ r"\pgfsys@transformcm{%f}{%f}{%f}{%f}{%fin}{%fin}" %
649
+ (tr1 * f , tr2 * f , tr3 * f , tr4 * f ,
650
+ (tr5 + x ) * f , (tr6 + y ) * f ))
651
+ w = h = 1 # scale is already included in the transform
652
+ interp = str (transform is None ).lower () # interpolation in PDF reader
653
+ writeln (self .fh ,
654
+ r"\pgftext[left,bottom]"
655
+ r"{\pgfimage[interpolate=%s,width=%fin,height=%fin]{%s}}" %
656
+ (interp , w , h , fname_img ))
631
657
writeln (self .fh , r"\end{pgfscope}" )
632
658
633
659
def draw_tex (self , gc , x , y , s , prop , angle , ismath = "TeX!" , mtext = None ):
0 commit comments