| 129 | self.ReadBusy() |
| 130 | |
| 131 | def getbuffer(self, image): |
| 132 | if self.width%8 == 0: |
| 133 | linewidth = int(self.width/8) |
| 134 | else: |
| 135 | linewidth = int(self.width/8) + 1 |
| 136 | |
| 137 | buf = [0xFF] * (linewidth * self.height) |
| 138 | image_monocolor = image.convert('1') |
| 139 | imwidth, imheight = image_monocolor.size |
| 140 | pixels = image_monocolor.load() |
| 141 | |
| 142 | if(imwidth == self.width and imheight == self.height): |
| 143 | logger.debug("Vertical") |
| 144 | for y in range(imheight): |
| 145 | for x in range(imwidth): |
| 146 | if pixels[x, y] == 0: |
| 147 | # x = imwidth - x |
| 148 | buf[int(x / 8) + y * linewidth] &= ~(0x80 >> (x % 8)) |
| 149 | elif(imwidth == self.height and imheight == self.width): |
| 150 | logger.debug("Horizontal") |
| 151 | for y in range(imheight): |
| 152 | for x in range(imwidth): |
| 153 | newx = y |
| 154 | newy = self.height - x - 1 |
| 155 | if pixels[x, y] == 0: |
| 156 | # newy = imwidth - newy - 1 |
| 157 | buf[int(newx / 8) + newy*linewidth] &= ~(0x80 >> (y % 8)) |
| 158 | return buf |
| 159 | |
| 160 | |
| 161 | def display(self, image): |