Comments (3)
Results of pngcheck on "master" branch:
Running `target/release/examples/pngcheck /Users/me/Downloads/font.png`
OK: /Users/me/Downloads/font.png (256x256, 1-bit palette, non-interlaced, 94.9%)
$ cargo run --release --example pngcheck -- -v ~/Downloads/font.png
Finished release [optimized] target(s) in 0.07s
Running `target/release/examples/pngcheck -v /Users/me/Downloads/font.png`
File: /Users/me/Downloads/font.png (10240) bytes
chunk ChunkType { type: IHDR, critical: true, private: false, reserved: false, safecopy: false } at offset 0x0000c, length 13
256 x 256 image, 1-bit palette, non-interlaced
chunk ChunkType { type: gAMA, critical: false, private: false, reserved: false, safecopy: false } at offset 0x00025, length 4
chunk ChunkType { type: sRGB, critical: false, private: false, reserved: false, safecopy: false } at offset 0x00035, length 1
chunk ChunkType { type: pHYs, critical: false, private: false, reserved: false, safecopy: true } at offset 0x00042, length 9
chunk ChunkType { type: PLTE, critical: true, private: false, reserved: false, safecopy: false } at offset 0x00057, length 6
chunk ChunkType { type: IDAT, critical: true, private: false, reserved: false, safecopy: false } at offset 0x00069, length 1256
chunk ChunkType { type: IEND, critical: true, private: false, reserved: false, safecopy: false } at offset 0x0055d, length 0
No errors detected in /Users/me/Downloads/font.png (7 chunks, 94.9% compression)
from image-png.
Hmm. Using the show
example, it does load properly.
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.
from image-png.
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!
from image-png.
Related Issues (20)
- `png::decoder::Row` is missing from the documentation HOT 1
- Support CICP HOT 5
- Large regression in time to complete tests HOT 2
- Public `StreamWriter::finish()` method is not documented
- Image decoded differently in v0.17.7 and v0.17.8-rc HOT 1
- Very slow decoding of paletted PNG images HOT 19
- The functions and constants under `png::chunk` should probably be methods and associated constants of `png::chunk::ChunkType`
- Compression filesize changes between v0.17.5 - v0.17.9 HOT 1
- afl binary cannot be built HOT 1
- Broken APNG is produced with `StreamWriter` HOT 2
- Discussion: PNG decoding performance improvement opportunities
- Avoiding `scratch_buffer` (a field of `struct Reader<R>`) HOT 1
- Re-encode example HOT 2
- Decoding fails with LimitsExceeded despite not exceeding limits HOT 1
- Crash when width=0
- Open questions about supporting Exif HOT 1
- Docs should say whether Rgba<T> is premultiplied or not HOT 3
- Panic on decoding a crafted image: `chunk size must be non-zero` HOT 2
- Infinite loop on decoding a crafted image HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from image-png.