MCPcopy Create free account
hub / github.com/Image-Py/imagepy / draw_image

Method draw_image

imagepy/ui/canvas.py:198–214  ·  view source on GitHub ↗
(self, dc, ndarr, back, mode, rect, scale, dirty)

Source from the content-addressed store, hash-verified

196 return rstarr
197
198 def draw_image(self, dc, ndarr, back, mode, rect, scale, dirty):
199 #print(rect, self.box)
200 win = cross(self.box, rect)
201 win2 = trans(rect, win)
202 sx = sy = 1.0/scale
203 box = multiply(win2, sx, sy)
204
205 M = np.array([sx, sy])
206 O = (win2[1]*sx, win2[0]*sy)
207 shape = (win2[3], win2[2])
208
209 if dirty:
210 start = time()
211 rst = self.merge(ndarr, back, M, O, mode, shape, win2, self.ips.lookup)
212 self.bmp = wx.Bitmap.FromBuffer(win2[2], win2[3], memoryview(rst))
213 print(time()-start)
214 dc.DrawBitmap(self.bmp, win[0], win[1])
215
216 def save_buffer(self, path):
217 self.buffer.SaveFile(path, wx.BITMAP_TYPE_PNG)

Callers 1

updateMethod · 0.95

Calls 4

mergeMethod · 0.95
crossFunction · 0.85
multiplyFunction · 0.85
transFunction · 0.70

Tested by

no test coverage detected