diff --git a/ffi.rs b/ffi.rs index 20c8137..b0b192e 100644 --- a/ffi.rs +++ b/ffi.rs @@ -27,7 +27,7 @@ pub static COLOR_TYPE_RGBA: c_int = 6; pub type png_struct = c_void; pub type png_info = c_void; -pub extern { +extern { // libc routines needed pub fn setjmp(env: *c_void) -> c_int; @@ -65,4 +65,4 @@ pub extern { pub fn png_set_IHDR(png_ptr: *png_struct, info_ptr: *mut png_info, width: u32, height: u32, bit_depth: c_int, color_type: c_int, interlace_method: c_int, compression_method: c_int, filter_method: c_int); pub fn png_set_pHYs(png_ptr: *png_struct, info_ptr: *mut png_info, res_x: u32, res_y: u32, unit_type: c_int); pub fn png_set_rows(png_ptr: *png_struct, info_ptr: *mut png_info, row_pointers: **u8); -} \ No newline at end of file +} diff --git a/lib.rs b/lib.rs index c8f7938..b3de270 100644 --- a/lib.rs +++ b/lib.rs @@ -94,10 +94,10 @@ pub fn load_png(path: &Path) -> Result { _ => fail!(~"color type not supported"), }; - let mut image_data = vec::from_elem(width * height * pixel_width as uint, 0u8); + let mut image_data = vec::from_elem((width * height * pixel_width) as uint, 0u8); let image_buf = vec::raw::to_mut_ptr(image_data); let row_pointers: ~[*mut u8] = do vec::from_fn(height as uint) |idx| { - ptr::mut_offset(image_buf, (width * pixel_width as uint) * idx) + ptr::mut_offset(image_buf, (((width * pixel_width) as uint) * idx) as int) }; ffi::png_read_image(png_ptr, vec::raw::to_ptr(row_pointers)); @@ -178,7 +178,7 @@ pub fn store_png(img: &Image, path: &Path) -> Result<(),~str> { let image_buf = vec::raw::to_ptr(img.pixels); let row_pointers: ~[*u8] = do vec::from_fn(img.height as uint) |idx| { - ptr::offset(image_buf, (img.width * pixel_width as uint) * idx) + ptr::offset(image_buf, (((img.width * pixel_width) as uint) * idx) as int) }; ffi::png_set_rows(&*png_ptr, info_ptr, vec::raw::to_ptr(row_pointers));