@@ -372,13 +372,18 @@ def text(self, string, x, y, color, *, font_name="font5x8.bin", size=1):
372372    def  image (self , img ):
373373        """Set buffer to value of Python Imaging Library image.  The image should 
374374        be in 1 bit mode and a size equal to the display size.""" 
375+         # determine our effective width/height, taking rotation into account 
376+         width  =  self .width 
377+         height  =  self .height 
378+         if  self .rotation  ==  1  or  self .rotation  ==  3 :
379+             width , height  =  height , width 
375380        if  img .mode  !=  "1" :
376381            raise  ValueError ("Image must be in mode 1." )
377382        imwidth , imheight  =  img .size 
378-         if  imwidth  !=  self . width  or  imheight  !=  self . height :
383+         if  imwidth  !=  width  or  imheight  !=  height :
379384            raise  ValueError (
380385                "Image must be same dimensions as display ({0}x{1})." .format (
381-                     self . width , self . height 
386+                     width , height 
382387                )
383388            )
384389        # Grab all the pixels from the image, faster than getpixel. 
@@ -387,8 +392,8 @@ def image(self, img):
387392        for  i  in  range (len (self .buf )):
388393            self .buf [i ] =  0 
389394        # Iterate through the pixels 
390-         for  x  in  range (self . width ):  # yes this double loop is slow, 
391-             for  y  in  range (self . height ):  #  but these displays are small! 
395+         for  x  in  range (width ):  # yes this double loop is slow, 
396+             for  y  in  range (height ):  #  but these displays are small! 
392397                if  pixels [(x , y )]:
393398                    self .pixel (x , y , 1 )  # only write if pixel is true 
394399
0 commit comments