Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hillin opened this issue Apr 14, 2024 · 0 comments
Open

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

hillin opened this issue Apr 14, 2024 · 0 comments

Comments

@hillin
Copy link

hillin commented Apr 14, 2024

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()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant