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

Read updated color type and width #31

Merged
merged 1 commit into from Apr 18, 2014
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

read updated color type and width

  • Loading branch information
evilpie committed Apr 18, 2014
commit 3633e1303f4b22e6738b293f5a7672e0ddbc1bba
5 lib.rs
@@ -132,7 +132,10 @@ pub fn load_png_from_memory(image: &[u8]) -> Result<Image,~str> {
ffi::png_set_interlace_handling(png_ptr);
ffi::png_read_update_info(png_ptr, info_ptr);

let (color_type, pixel_width) = match (color_type as c_int, bit_depth) {
let updated_color_type = ffi::png_get_bit_depth(&*png_ptr, &*info_ptr);
let updated_bit_depth = ffi::png_get_color_type(&*png_ptr, &*info_ptr);

let (color_type, pixel_width) = match (updated_color_type as c_int, updated_bit_depth) {
(ffi::COLOR_TYPE_RGB, 8) |
(ffi::COLOR_TYPE_RGBA, 8) |
(ffi::COLOR_TYPE_PALETTE, 8) => (RGBA8, 4),
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.