コード例 #1
0
    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'
コード例 #2
0
ファイル: document.py プロジェクト: manuq/gegl-examples-old
    def blit_tile_into(self,
                       dst,
                       dst_has_alpha,
                       tx,
                       ty,
                       mipmap_level=0,
                       layers=None,
                       background=None):
        assert dst_has_alpha is False
        if layers is None:
            layers = self.layers
        if background is None:
            background = self.background

        assert dst.shape[-1] == 4
        if dst.dtype == 'uint8':
            dst_8bit = dst
            dst = numpy.empty((N, N, 4), dtype='uint16')
        else:
            dst_8bit = None

        background.blit_tile_into(dst, dst_has_alpha, tx, ty, mipmap_level)

        for layer in layers:
            layer.composite_tile(dst, dst_has_alpha, tx, ty, mipmap_level)

        if dst_8bit is not None:
            mypaintlib.tile_convert_rgbu16_to_rgbu8(dst, dst_8bit)
コード例 #3
0
ファイル: tiledsurface.py プロジェクト: j-fu/mypaint
    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)
コード例 #4
0
ファイル: tiledsurface.py プロジェクト: sjcalamia/mypaint
    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)
コード例 #5
0
ファイル: backgroundsurface.py プロジェクト: dvberkel/mypaint
 def blit_tile_into(self, dst, dst_has_alpha, tx, ty, mipmap_level=0):
     assert dst_has_alpha is False
     if self.mipmap_level < mipmap_level:
         return self.mipmap.blit_tile_into(dst, dst_has_alpha, tx, ty, mipmap_level)
     rgbu = 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':
         # this will do memcpy, not worth to bother skipping the u channel
         mypaintlib.tile_copy_rgba16_into_rgba16(rgbu, 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_rgbu16_to_rgbu8(rgbu, dst)
コード例 #6
0
ファイル: document.py プロジェクト: jesterKing/mypaint-xsheet
    def blit_tile_into(self, dst, dst_has_alpha, tx, ty, mipmap_level=0, layers=None, background=None):
        assert dst_has_alpha is False
        if layers is None:
            layers = self.layers
        if background is None:
            background = self.background

        assert dst.shape[-1] == 4
        if dst.dtype == 'uint8':
            dst_8bit = dst
            dst = numpy.empty((N, N, 4), dtype='uint16')
        else:
            dst_8bit = None

        background.blit_tile_into(dst, dst_has_alpha, tx, ty, mipmap_level)

        for layer in layers:
            layer.composite_tile(dst, dst_has_alpha, tx, ty, mipmap_level)

        if dst_8bit is not None:
            mypaintlib.tile_convert_rgbu16_to_rgbu8(dst, dst_8bit)
コード例 #7
0
    def blit_tile_into(self, dst_8bit, dst_has_alpha, tx, ty, mipmap_level=0, layers=None, background=None):
        assert dst_has_alpha is False
        if layers is None:
            layers = self.layers
        if background is None:
            background = self.background

        assert dst_8bit.dtype == 'uint8'
        assert dst_8bit.shape[-1] == 4
        dst = numpy.empty((N, N, 4), dtype='uint16')

        background.blit_tile_into(dst, dst_has_alpha, tx, ty, mipmap_level)

        for layer in layers:
            surface = layer._surface
            surface.composite_tile(dst, dst_has_alpha, tx, ty,
                    mipmap_level=mipmap_level,
                    opacity=layer.effective_opacity,
                    mode=layer.compositeop)

        mypaintlib.tile_convert_rgbu16_to_rgbu8(dst, dst_8bit)
コード例 #8
0
ファイル: tiledsurface.py プロジェクト: vendettaboom/mypaint
    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)