MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / getbuffer

Method getbuffer

resources/waveshare_epd/epd2in7.py:366–388  ·  view source on GitHub ↗
(self, image)

Source from the content-addressed store, hash-verified

364 self.send_data(0x57)
365
366 def getbuffer(self, image):
367 # logger.debug("bufsiz = ",int(self.width/8) * self.height)
368 buf = [0xFF] * (int(self.width/8) * self.height)
369 image_monocolor = image.convert('1')
370 imwidth, imheight = image_monocolor.size
371 pixels = image_monocolor.load()
372 # logger.debug("imwidth = %d, imheight = %d",imwidth,imheight)
373 if(imwidth == self.width and imheight == self.height):
374 logger.debug("Vertical")
375 for y in range(imheight):
376 for x in range(imwidth):
377 # Set the bits for the column of pixels at the current position.
378 if pixels[x, y] == 0:
379 buf[int((x + y * self.width) / 8)] &= ~(0x80 >> (x % 8))
380 elif(imwidth == self.height and imheight == self.width):
381 logger.debug("Horizontal")
382 for y in range(imheight):
383 for x in range(imwidth):
384 newx = y
385 newy = self.height - x - 1
386 if pixels[x, y] == 0:
387 buf[int((newx + newy*self.width) / 8)] &= ~(0x80 >> (y % 8))
388 return buf
389
390 def getbuffer_4Gray(self, image):
391 # logger.debug("bufsiz = ",int(self.width/8) * self.height)

Callers

nothing calls this directly

Calls 2

rangeFunction · 0.85
debugMethod · 0.80

Tested by

no test coverage detected