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

Method getbuffer

resources/waveshare_epd/epd3in7.py:238–260  ·  view source on GitHub ↗
(self, image)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 2

rangeFunction · 0.85
debugMethod · 0.80

Tested by

no test coverage detected