コード例 #1
0
ファイル: bitmap.py プロジェクト: fenixchen/osd_engine
    def draw_line(self, window_line_buf, window, y, block_x):
        if y >= self.height:
            return
        if self._tiled:
            width = min(self._width, window.width - block_x)
        else:
            width = min(self._bitmap_width, self._width,
                        window.width - block_x)

        start = self._current * self._bitmap_width * self._bitmap_height \
                + self._bitmap_width * (y % self._bitmap_height)

        cx = start
        for x in range(start, start + width):
            index = self._data[cx]
            col = block_x + x - start
            if self._mask_color is None:
                color = self.get_color(index)
                if 0 <= col < window.width and color != self._transparent_color:
                    window_line_buf[col] = color
            else:
                color = self.get_color(self._mask_color)
                intensity = index
                if 0 <= col < window.width and intensity > 0:
                    window_line_buf[col] = ImageUtil.blend_pixel(
                        window_line_buf[col], color, intensity)

            cx = cx + 1
            if cx - start >= self._bitmap_width:
                cx = start
コード例 #2
0
ファイル: scene.py プロジェクト: fenixchen/MindMap
 def merge_line(self, dst_buf, src_buf, src_buf_offset, src_alpha):
     """
     blending源buffer到目的buffer中
     """
     assert (src_buf_offset + len(src_buf) < self._width)
     for x in range(src_buf_offset, src_buf_offset + len(src_buf)):
         dst_buf[x] = ImageUtil.blend_pixel(dst_buf[x],
                                            src_buf[x - src_buf_offset],
                                            src_alpha)
コード例 #3
0
ファイル: glyph.py プロジェクト: fenixchen/MindMap
 def draw_line(self, line_buf, window, y, block_x):
     assert (0 <= y < self._height)
     color = self.color(window, self._color)
     width = min(self._width, window.width - block_x)
     for x in range(self._pitch * y, self._pitch * y + width):
         index = self._data[x]
         if index == 0:
             continue
         col = block_x + x - self._width * y
         line_buf[col] = ImageUtil.blend_pixel(line_buf[col], color,
                                               index / 255)
コード例 #4
0
ファイル: text.py プロジェクト: fenixchen/osd_engine
    def draw_line(self, window_line_buf, window, y, block_x):
        top = self.top_line()
        color = self.get_color(self._color)
        left = block_x
        for glyph in self._glyphs:
            col = left + glyph.left
            left += glyph.advance_x
            if not 0 <= y - glyph.top + top < glyph.height:
                continue

            offset = (y - glyph.top + top) * glyph.pitch
            for x in range(glyph.width):
                if glyph.monochrome:
                    bit = glyph.data[offset + (x >> 3)]
                    bit = bit & (128 >> (x & 7))
                    if 0 <= col < window.width and bit > 0:
                        window_line_buf[col] = color
                else:
                    intensity = glyph.data[offset + x]
                    if 0 <= col < window.width and intensity > 0:
                        window_line_buf[col] = ImageUtil.blend_pixel(
                            window_line_buf[col], color, intensity)
                col += 1