def blit_tile_into(self, dst, dst_has_alpha, tx, ty, mipmap_level=0): # used mainly for saving (transparent PNG) #assert dst_has_alpha is True if self.mipmap_level < mipmap_level: return self.mipmap.blit_tile_into(dst, dst_has_alpha, tx, ty, mipmap_level) assert dst.shape[2] == 4 with self.tile_request(tx, ty, readonly=True) as src: if src is transparent_tile.rgba: #dst[:] = 0 # <-- notably slower than memset() mypaintlib.tile_clear(dst) else: if dst.dtype == 'uint16': # this will do memcpy, not worth to bother skipping the u channel mypaintlib.tile_copy_rgba16_into_rgba16(src, dst) elif dst.dtype == 'uint8': if dst_has_alpha: mypaintlib.tile_convert_rgba16_to_rgba8(src, dst) else: mypaintlib.tile_convert_rgbu16_to_rgbu8(src, dst) else: raise ValueError, 'Unsupported destination buffer type'
def blit_tile_into(self, dst, dst_has_alpha, tx, ty, mipmap_level=0): # used mainly for saving (transparent PNG) #assert dst_has_alpha is True if self.mipmap_level < mipmap_level: return self.mipmap.blit_tile_into(dst, dst_has_alpha, tx, ty, mipmap_level) assert dst.shape[2] == 4 if dst.dtype not in ('uint16', 'uint8'): raise ValueError('Unsupported destination buffer type %r', dst.dtype) dst_is_uint16 = (dst.dtype == 'uint16') with self.tile_request(tx, ty, readonly=True) as src: if src is transparent_tile.rgba: #dst[:] = 0 # <-- notably slower than memset() if dst_is_uint16: mypaintlib.tile_clear_rgba16(dst) else: mypaintlib.tile_clear_rgba8(dst) else: if dst_is_uint16: # this will do memcpy, not worth to bother skipping the u channel mypaintlib.tile_copy_rgba16_into_rgba16(src, dst) else: if dst_has_alpha: mypaintlib.tile_convert_rgba16_to_rgba8(src, dst) else: mypaintlib.tile_convert_rgbu16_to_rgbu8(src, dst)
def blit_tile_into(self, dst, tx, ty, mipmap_level=0): # used mainly for saving (transparent PNG) if self.mipmap_level < mipmap_level: return self.mipmap.blit_tile_into(dst, tx, ty, mipmap_level) assert dst.shape[2] == 4 src = self.get_tile_memory(tx, ty, readonly=True) if src is transparent_tile.rgba: #dst[:] = 0 # <-- notably slower than memset() mypaintlib.tile_clear(dst) else: mypaintlib.tile_convert_rgba16_to_rgba8(src, dst)
def blit_tile_into(self, dst, dst_has_alpha, tx, ty, mipmap_level=0, *args, **kwargs): """Copy one tile from this object into a destination array See lib.surface.TileBlittable for the parameters. This implementation adds an extra param: :param int mipmap_level: layer mipmap level to use Used mainly for saving (transparent PNG). """ # assert dst_has_alpha is True if self.mipmap_level < mipmap_level: return self.mipmap.blit_tile_into(dst, dst_has_alpha, tx, ty, mipmap_level) assert dst.shape[2] == 4 if dst.dtype not in ('uint16', 'uint8'): raise ValueError('Unsupported destination buffer type %r', dst.dtype) dst_is_uint16 = (dst.dtype == 'uint16') with self.tile_request(tx, ty, readonly=True) as src: if src is transparent_tile.rgba: # dst[:] = 0 # <-- notably slower than memset() if dst_is_uint16: mypaintlib.tile_clear_rgba16(dst) else: mypaintlib.tile_clear_rgba8(dst) else: if dst_is_uint16: # this will do memcpy, not worth to bother skipping # the u channel mypaintlib.tile_copy_rgba16_into_rgba16(src, dst) else: if dst_has_alpha: mypaintlib.tile_convert_rgba16_to_rgba8(src, dst) else: mypaintlib.tile_convert_rgbu16_to_rgbu8(src, dst)
def blit_tile_into(self, dst, dst_has_alpha, tx, ty, mipmap_level=0, *args, **kwargs): """Copy one tile from this object into a destination array See lib.surface.TileBlittable for the parameters. This implementation adds an extra param: :param int mipmap_level: layer mipmap level to use """ # used mainly for saving (transparent PNG) #assert dst_has_alpha is True if self.mipmap_level < mipmap_level: return self.mipmap.blit_tile_into(dst, dst_has_alpha, tx, ty, mipmap_level) assert dst.shape[2] == 4 if dst.dtype not in ('uint16', 'uint8'): raise ValueError('Unsupported destination buffer type %r', dst.dtype) dst_is_uint16 = (dst.dtype == 'uint16') with self.tile_request(tx, ty, readonly=True) as src: if src is transparent_tile.rgba: #dst[:] = 0 # <-- notably slower than memset() if dst_is_uint16: mypaintlib.tile_clear_rgba16(dst) else: mypaintlib.tile_clear_rgba8(dst) else: if dst_is_uint16: # this will do memcpy, not worth to bother skipping the u channel mypaintlib.tile_copy_rgba16_into_rgba16(src, dst) else: if dst_has_alpha: mypaintlib.tile_convert_rgba16_to_rgba8(src, dst) else: mypaintlib.tile_convert_rgbu16_to_rgbu8(src, dst)