-
Notifications
You must be signed in to change notification settings - Fork 141
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 longer able to decode certain palletized PNGs #448
Comments
Results of pngcheck on "master" branch:
|
Hmm. Using the My code to load the image looks like this: let decoder = Decoder::new(file);
let mut reader = match decoder.read_info() {
Ok(x) => x,
Err(x) => match x {
DecodingError::IoError(x) => return Err(x),
_ => panic!("Unable to decode image header")
}
};
// Load the image
let mut pixels = vec![0; reader.output_buffer_size()];
match reader.next_frame(&mut pixels) {
Ok(_) => {},
Err(x) => match x {
DecodingError::IoError(x) => return Err(x),
_ => panic!("Unable to decode image file")
}
};
let image_info = reader.info();
self.width = image_info.width as usize;
self.height = image_info.height as usize;
...
unsafe {
gl::TexImage2D(gl::TEXTURE_2D,
0,
gl::RGBA8 as i32,
self.width as GLsizei,
self.height as GLsizei,
0,
gl::RGBA,
gl::UNSIGNED_BYTE,
pixels.as_ptr() as *const GLvoid);
} I'm guessing that at some point, the in-memory representation of the image changes from RGBA? This seems like user error at this point so I'll focus on trying to fix my work, but let me know if it's worth creating a test case. |
Fixed by setting transformations on the decoder: decoder.set_transformations(Transformations::ALPHA); Sorry for the noise all! I've been pretty happy with this crate so far, keep up the great work! |
I've been using the
png
crate for about four years on a personal project. In the beginning (some years ago) palletized PNG files worked fine. About a year or so ago, it began to fail to load at all and resulted in a fatal error I don't quite recall.Here are the two images. First, the one that fails:
And the one that succeeds:
I'm using
pngquant
2.18.0 (January 2023) at the moment, but as mentioned before it's been an issue for some time. When decoding, I get the following (teal is transparent)Instead of this:
The text was updated successfully, but these errors were encountered: