@@ -609,7 +609,20 @@ def _pgf_path_draw(self, stroke=True, fill=False):
609609 actions .append ("fill" )
610610 writeln (self .fh , r"\pgfusepath{%s}" % "," .join (actions ))
611611
612- def draw_image (self , gc , x , y , im ):
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 ):
613626 # TODO: Almost no documentation for the behavior of this function.
614627 # Something missing?
615628 h , w = im .shape [:2 ]
@@ -627,7 +640,17 @@ def draw_image(self, gc, x, y, im):
627640 writeln (self .fh , r"\begin{pgfscope}" )
628641 self ._print_pgf_clip (gc )
629642 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 ))
643+ if transform is not None :
644+ tr1 , tr2 , tr3 , tr4 , tr5 , tr6 = transform .frozen ().to_values ()
645+ # scale is already included in the above transform
646+ w , h = 1 , 1
647+ # translation can be merged into this transform (makes it easier)
648+ tr5 += x
649+ tr6 += y
650+ x , y = 0 , 0
651+ writeln (self .fh , r"\makeatletter\pgfsys@transformcm{%f}{%f}{%f}{%f}{%fin}{%fin}\makeatother" % (tr1 , tr2 , tr3 , tr4 , tr5 * f , tr6 * f ))
652+ interp = str (transform is None ).lower () # interpolation in PDF reader
653+ writeln (self .fh , r"\pgftext[at=\pgfqpoint{%fin}{%fin},left,bottom]{\pgfimage[interpolate=%s,width=%fin,height=%fin]{%s}}" % (x * f , y * f , interp , w * f , h * f , fname_img ))
631654 writeln (self .fh , r"\end{pgfscope}" )
632655
633656 def draw_tex (self , gc , x , y , s , prop , angle , ismath = "TeX!" , mtext = None ):
0 commit comments