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

Update to latest Rust #4

Merged
merged 1 commit into from Aug 8, 2013
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Update to latest Rust

  • Loading branch information
kmcallister committed Aug 6, 2013
commit fe3b0e137f553dbd291e2558a9e7369b32ff9b4d
4 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);
}
}
6 lib.rs
@@ -94,10 +94,10 @@ pub fn load_png(path: &Path) -> Result<Image,~str> {
_ => 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));

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.