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

Method getbuffer

resources/waveshare_epd/epd2in13.py:131–158  ·  view source on GitHub ↗
(self, image)

Source from the content-addressed store, hash-verified

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):

Callers

nothing calls this directly

Calls 2

rangeFunction · 0.85
debugMethod · 0.80

Tested by

no test coverage detected