diff --git a/src/wand/magick.rs b/src/wand/magick.rs index 7b82439..55631a6 100644 --- a/src/wand/magick.rs +++ b/src/wand/magick.rs @@ -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. pub fn set_image_background_color(&self, pixel_wand: &PixelWand) -> Result<(), &'static str> { match unsafe { bindings::MagickSetImageBackgroundColor(self.wand, pixel_wand.wand) } { diff --git a/tests/data/rust.svg b/tests/data/rust.svg new file mode 100644 index 0000000..65ac6b1 --- /dev/null +++ b/tests/data/rust.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/tests/lib.rs b/tests/lib.rs index 9d9fccb..89a7991 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -303,3 +303,20 @@ fn test_set_image_background_color() { assert_eq!(0u8, blob[1]); 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]); +} \ No newline at end of file