Exemplo n.º 1
0
def write_targa_bgrx(stream, dimensions, depth_bits, pixels_bgrx):
    stream_pack(stream, '<BBBHHBHHHHBB',
                0, #  id_length
                0,  # colormap_type
                2,  # image_type: BGR(A)
                0,  # colormap_index
                0,  # colormap_length
                0,  # colormap_size
                0,  # x_origin
                0,  # y_origin
                dimensions[0], # width
                dimensions[1], # height
                depth_bits,  # pixel_size: 24 (BGR) | 32 (BGRA)
                0x00)  # attributes
    stream_write(stream, pixels_bgrx)
Exemplo n.º 2
0
def write_targa_bgrx(stream, size, depth_bits, pixels_bgrx):
    stream_pack(stream, '<BBBHHBHHHHBB',
                0,  #  id_length
                0,  # colormap_type
                2,  # image_type: BGR(A)
                0,  # colormap_index
                0,  # colormap_length
                0,  # colormap_size
                0,  # x_origin
                0,  # y_origin
                size[0],  # width
                size[1],  # height
                depth_bits,  # pixel_size: 24 (BGR) | 32 (BGRA)
                0x00)  # attributes
    stream_write(stream, pixels_bgrx)
Exemplo n.º 3
0
def jascpal_write(stream, palette):
    assert palette
    stream_write(stream, 'JASC-PAL\n')
    stream_write(stream, '0100\n')
    stream_write(stream, '{:d}\n'.format(len(palette)))
    for r, g, b in palette:
        assert 0x00 <= r <= 0xFF
        assert 0x00 <= g <= 0xFF
        assert 0x00 <= b <= 0xFF
        stream_write(stream, '{:d} {:d} {:d}\n'.format(r, g, b))
Exemplo n.º 4
0
def jascpal_write(stream, palette):
    assert palette
    stream_write(stream, 'JASC-PAL\n')
    stream_write(stream, '0100\n')
    stream_write(stream, '{:d}\n'.format(len(palette)))
    for r, g, b in palette:
        assert 0x00 <= r <= 0xFF
        assert 0x00 <= g <= 0xFF
        assert 0x00 <= b <= 0xFF
        stream_write(stream, '{:d} {:d} {:d}\n'.format(r, g, b))
Exemplo n.º 5
0
 def to_stream(self, stream):
     self.header.to_stream(stream)
     stream_write(stream, self.events)
Exemplo n.º 6
0
 def to_stream(self, stream):
     stream_write(stream, self.to_bytes())