| 236 | return 0 |
| 237 | |
| 238 | def getbuffer(self, image): |
| 239 | # logger.debug("bufsiz = ",int(self.width/8) * self.height) |
| 240 | buf = [0xFF] * (int(self.width / 8) * self.height) |
| 241 | image_monocolor = image.convert('1') |
| 242 | imwidth, imheight = image_monocolor.size |
| 243 | pixels = image_monocolor.load() |
| 244 | # logger.debug("imwidth = %d, imheight = %d",imwidth,imheight) |
| 245 | if(imwidth == self.width and imheight == self.height): |
| 246 | logger.debug("Vertical") |
| 247 | for y in range(imheight): |
| 248 | for x in range(imwidth): |
| 249 | # Set the bits for the column of pixels at the current position. |
| 250 | if pixels[x, y] == 0: |
| 251 | buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8)) |
| 252 | elif(imwidth == self.height and imheight == self.width): |
| 253 | logger.debug("Horizontal") |
| 254 | for y in range(imheight): |
| 255 | for x in range(imwidth): |
| 256 | newx = y |
| 257 | newy = self.height - x - 1 |
| 258 | if pixels[x, y] == 0: |
| 259 | buf[int((newx + newy * self.width) / 8)] &= ~(0x80 >> (y % 8)) |
| 260 | return buf |
| 261 | |
| 262 | def getbuffer_4Gray(self, image): |
| 263 | # logger.debug("bufsiz = ",int(self.width/4) * self.height) |