Binding for set_background_color
This commit is contained in:
@ -437,6 +437,15 @@ impl MagickWand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the background color.
|
||||||
|
pub fn set_background_color(&self, pixel_wand: &PixelWand) -> Result<(), &'static str> {
|
||||||
|
match unsafe { bindings::MagickSetBackgroundColor(self.wand, pixel_wand.wand) } {
|
||||||
|
bindings::MagickBooleanType_MagickTrue => Ok(()),
|
||||||
|
|
||||||
|
_ => Err("SetBackgroundColor returned false"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Set the image background color.
|
/// Set the image background color.
|
||||||
pub fn set_image_background_color(&self, pixel_wand: &PixelWand) -> Result<(), &'static str> {
|
pub fn set_image_background_color(&self, pixel_wand: &PixelWand) -> Result<(), &'static str> {
|
||||||
match unsafe { bindings::MagickSetImageBackgroundColor(self.wand, pixel_wand.wand) } {
|
match unsafe { bindings::MagickSetImageBackgroundColor(self.wand, pixel_wand.wand) } {
|
||||||
|
|||||||
2
tests/data/rust.svg
Normal file
2
tests/data/rust.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 7.5 KiB |
17
tests/lib.rs
17
tests/lib.rs
@ -303,3 +303,20 @@ fn test_set_image_background_color() {
|
|||||||
assert_eq!(0u8, blob[1]);
|
assert_eq!(0u8, blob[1]);
|
||||||
assert_eq!(255u8, blob[2]);
|
assert_eq!(255u8, blob[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_set_background_color() {
|
||||||
|
START.call_once(|| {
|
||||||
|
magick_wand_genesis();
|
||||||
|
});
|
||||||
|
let wand = MagickWand::new();
|
||||||
|
let mut pw = PixelWand::new();
|
||||||
|
pw.set_color("none").unwrap();
|
||||||
|
wand.set_background_color(&pw).unwrap();
|
||||||
|
assert!(wand.read_image("tests/data/rust.svg").is_ok());
|
||||||
|
let blob = wand.write_image_blob("rgba").unwrap();
|
||||||
|
assert_eq!(0u8, blob[0]);
|
||||||
|
assert_eq!(0u8, blob[1]);
|
||||||
|
assert_eq!(0u8, blob[2]);
|
||||||
|
assert_eq!(0u8, blob[3]);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user