def blit_tile_into(self, dst_8bit, tx, ty, mipmap_level=0, layers=None, background=None): if layers is None: layers = self.layers if background is None: background = self.background assert dst_8bit.dtype == 'uint8' dst = numpy.empty((N, N, 3), dtype='uint16') background.blit_tile_into(dst, tx, ty, mipmap_level) for layer in layers: surface = layer.surface surface.composite_tile_over(dst, tx, ty, mipmap_level=mipmap_level, opacity=layer.effective_opacity) mypaintlib.tile_convert_rgb16_to_rgb8(dst, dst_8bit)
def blit_tile_into(self, dst, tx, ty, mipmap_level=0): if self.mipmap_level < mipmap_level: return self.mipmap.blit_tile_into(dst, tx, ty, mipmap_level) rgb = self.get_tile_memory(tx, ty) # render solid or tiled background #dst[:] = rgb # 13 times slower than below, with some bursts having the same speed as below (huh?) # note: optimization for solid colors is not worth it, it gives only 2x speedup (at best) if dst.dtype == 'uint16': mypaintlib.tile_blit_rgb16_into_rgb16(rgb, dst) else: # this case is for saving the background assert dst.dtype == 'uint8' # note: when saving the background layer we usually # convert here the same tile over and over again. But it # does help much to cache this conversion result. The # save_ora speedup when doing this is below 1%, even for a # single-layer ora. mypaintlib.tile_convert_rgb16_to_rgb8(rgb, dst)
def blit_tile_into(self, dst_8bit, tx, ty, mipmap_level=0, layers=None, background=None): if layers is None: layers = self.layers if background is None: background = self.background assert dst_8bit.dtype == 'uint8' dst = numpy.empty((N, N, 3), dtype='uint16') background.blit_tile_into(dst, tx, ty, mipmap_level) for layer in layers: surface = layer._surface surface.composite_tile(dst, tx, ty, mipmap_level=mipmap_level, opacity=layer.effective_opacity, mode=layer.compositeop) mypaintlib.tile_convert_rgb16_to_rgb8(dst, dst_8bit)