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

No transparency #2

Closed
AngReload opened this issue Mar 15, 2019 · 3 comments
Closed

No transparency #2

AngReload opened this issue Mar 15, 2019 · 3 comments

Comments

@AngReload
Copy link

Any GIFs having transparent pixels are decoded as full opaque.
For example: https://upload.wikimedia.org/wikipedia/commons/c/ce/Transparent.gif

#[test]
fn minimal_example() {
    let file = File::open("tests/Transparent.gif").unwrap();
    let mut decoder = gif::Decoder::new(file);

    decoder.set(gif::ColorOutput::Indexed);

    let mut reader = decoder.read_info().unwrap();

    let mut screen = gif_dispose::Screen::new_reader(&reader);
    while let Some(frame) = reader.read_next_frame().unwrap() {
        screen.blit_frame(&frame).unwrap();

        let mut t = "alpha == 255";
        for pixel in screen.pixels.as_ref() {
            if pixel.a != 255 {
                t = "transparent";
            }
        }
        println!("{}", t); // "alpha == 255"
    }
}
@kornelski
Copy link
Owner

Thanks for the report.

I've assumed that when a GIF has a background color set, it wants to have a background. This image does set background color to index 0.

@kornelski
Copy link
Owner

For this image I think fe9b8a3 solves it.

I've also found another issue, which I don't know how to solve: image-rs/image-gif#52

@AngReload
Copy link
Author

Okay, this only works for the first frame. Looks like we have to wait a decision on the issue gif-crate.

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

2 participants