Skip to content

RGBA image with A=255 is encoded as RGB image #37

@hillin

Description

@hillin
webp = "0.2.7"
fn main() {
    const WIDTH: usize = 4;
    const HEIGHT: usize = 4;

    // create an RGBA image, note all the alpha values are 255
    let data = vec![255u8; WIDTH * HEIGHT * 4];
    let encoder = webp::Encoder::from_rgba(&data, WIDTH as u32, HEIGHT as u32);

    // encode then decode it
    let encoded_data = encoder.encode_lossless().to_vec();
    let decoder = webp::Decoder::new(&encoded_data);
    let decoded_image = decoder.decode().unwrap();

    // it becomes an RGB image
    assert(decoded_image.is_alpha(), true);    // assertion failed: decoded_image.is_alpha()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions