def draw_image(self, x, y, dx, dy, scale, png_data): png_stream = io.StringIO(png_data) image = wx.ImageFromStream(png_stream) w = image.GetWidth() h = image.GetHeight() (x_scale, y_scale) = self._scale_image(x, y, dx, dy, scale, w, h) if scale < 4: image.Rescale(w * x_scale, h * y_scale) bmp = image.ConvertToBitmap() w = image.GetWidth() h = image.GetHeight() self.ctx.DrawBitmap(bmp, x, y, w, h) else: delta_x = 0 delta_y = 0 while delta_y < dy: if scale == 4 and delta_y > 0: break delta_x = 0 bmp = image.ConvertToBitmap() while delta_x < dx: if scale == 5 and delta_x > 0: break self.ctx.DrawBitmap(bmp, x + delta_x, y + delta_y, w, h) delta_x += w delta_y += h BaseDc.draw_image(self, x, y, dx, dy, scale, png_data)
def draw_image(self, x, y, dx, dy, scale, png_data): png_stream = io.BytesIO(png_data) image = PIL.Image.open(png_stream) w, h = image.size (x_scale, y_scale) = self._scale_image( x, y, dx, dy, scale, w, h, ) if scale < 4: if scale != 0 and x_scale < 0.25 and y_scale < 0.25: image.thumbnail((4 * w * x_scale, 4 * h * y_scale), PIL.Image.ANTIALIAS) file_name = get_temp_filename("temp.png") image.save(file_name, "PNG") self.dc.image(file_name, x, y, w * x_scale, h * y_scale) os.remove(file_name) else: pass BaseDc.draw_image(self, x, y, dx, dy, scale, png_data)