add drawing and pixel wands; add some methods to MagickWand

This commit is contained in:
Mattis Marjak
2016-05-11 22:12:42 +03:00
parent 4c7cebe628
commit 9e2285a4aa
7 changed files with 545 additions and 18 deletions

View File

@ -32,8 +32,9 @@
extern crate libc;
mod wand;
mod bindings { include!(concat!(env!("OUT_DIR"), "/bindings.rs")); }
mod conversions;
pub mod filters;
mod bindings { include!(concat!(env!("OUT_DIR"), "/bindings.rs")); }
pub use wand::*;
@ -59,3 +60,21 @@ pub fn magick_wand_terminus() {
}
}
}
pub fn magick_query_fonts(pattern: &str) -> Result<Vec<String>, &'static str> {
let mut number_fonts: u64 = 0;
let c_string = try!(::std::ffi::CString::new(pattern).map_err(|_| "could not convert to cstring"));
let ptr = unsafe { bindings::MagickQueryFonts(c_string.as_ptr(), &mut number_fonts as *mut _) };
if ptr.is_null() {
Err("null ptr returned by magick_query_fonts")
} else {
let mut v = Vec::new();
let c_str_ptr_slice = unsafe { ::std::slice::from_raw_parts(ptr, number_fonts as usize) };
for c_str_ptr in c_str_ptr_slice {
let c_str = unsafe { ::std::ffi::CStr::from_ptr(*c_str_ptr) };
v.push(c_str.to_string_lossy().into_owned())
}
Ok(v)
}
}