Example #1
0
def test_layer_record():
    tagged_blocks = TaggedBlocks([
        (TaggedBlockID.LAYER_VERSION, TaggedBlock(key=TaggedBlockID.LAYER_VERSION, data=IntegerElement(0))),
    ])
    check_write_read(LayerRecord())
    check_write_read(LayerRecord(name='foo', tagged_blocks=tagged_blocks))
    check_write_read(LayerRecord(tagged_blocks=tagged_blocks), version=2)
def test_layer_record_channel_sizes():
    layer_record = LayerRecord(
        left=0,
        top=0,
        right=100,
        bottom=120,
        channel_info=[
            ChannelInfo(id=ChannelID.CHANNEL_0),
            ChannelInfo(id=ChannelID.USER_LAYER_MASK),
            ChannelInfo(id=ChannelID.REAL_USER_LAYER_MASK),
        ],
        mask_data=MaskData(
            left=20,
            top=20,
            right=80,
            bottom=90,
            real_left=10,
            real_top=10,
            real_right=90,
            real_bottom=100,
        ))
    channel_sizes = layer_record.channel_sizes
    assert len(channel_sizes) == 3
    assert channel_sizes[0] == (100, 120)
    assert channel_sizes[1] == (60, 70)
    assert channel_sizes[2] == (80, 90)
Example #3
0
def test_channel_image_data():
    check_write_read(ChannelImageData(), layer_records=LayerRecords())

    layer_records = LayerRecords(
        [LayerRecord(channel_info=[
            ChannelInfo(id=0, length=18),
            ChannelInfo(id=-1, length=18),
        ])])
    channel_data_list = ChannelDataList([
        ChannelData(0, b'\xff' * 16),
        ChannelData(0, b'\xff' * 16),
    ])
    check_write_read(ChannelImageData([channel_data_list]), layer_records=layer_records)
Example #4
0
def test_layer_info():
    check_write_read(LayerInfo())

    layer_records = LayerRecords(
        [LayerRecord(channel_info=[
            ChannelInfo(id=0, length=18),
            ChannelInfo(id=-1, length=18),
        ])])
    channel_image_data = ChannelImageData(
        [ChannelDataList([
            ChannelData(0, b'\xff' * 16),
            ChannelData(0, b'\xff' * 16),
        ])])

    check_write_read(LayerInfo(1, layer_records, channel_image_data))