Binding for MagickClutImage

This commit is contained in:
Daniel Rönnkvist
2020-03-25 14:27:33 +01:00
parent 7d805d9a83
commit 97d620beb8
2 changed files with 34 additions and 0 deletions

View File

@ -230,6 +230,19 @@ impl MagickWand {
} }
} }
// Replaces colors in the image from a color lookup table.
pub fn clut_image(
&self,
clut_wand: &MagickWand,
method: bindings::PixelInterpolateMethod,
) -> Result<(), &'static str> {
let result = unsafe { bindings::MagickClutImage(self.wand, clut_wand.wand, method) };
match result {
bindings::MagickBooleanType_MagickTrue => Ok(()),
_ => Err("failed to replace colors in the image from color lookup table"),
}
}
pub fn set_size(&self, columns: size_t, rows: size_t) -> Result<(), &'static str> { pub fn set_size(&self, columns: size_t, rows: size_t) -> Result<(), &'static str> {
let result = unsafe { bindings::MagickSetSize(self.wand, columns, rows) }; let result = unsafe { bindings::MagickSetSize(self.wand, columns, rows) };
match result { match result {

View File

@ -325,3 +325,24 @@ fn test_set_size() {
let wand = MagickWand::new(); let wand = MagickWand::new();
assert!(wand.set_size(100, 100).is_ok()); assert!(wand.set_size(100, 100).is_ok());
} }
#[test]
fn test_clut_image() {
START.call_once(|| {
magick_wand_genesis();
});
let wand = MagickWand::new();
assert!(wand.read_image("tests/data/IMG_5745.JPG").is_ok());
let mut gradient = MagickWand::new();
assert!(gradient.set_size(128, 20).is_ok());
assert!(gradient.set_option("gradient:angle", "90").is_ok());
assert!(gradient.read_image("gradient:black-yellow").is_ok());
assert!(wand
.clut_image(
&gradient,
bindings::PixelInterpolateMethod_BilinearInterpolatePixel
)
.is_ok());
}