Binding for set_image_background_color
This commit is contained in:
36
tests/lib.rs
36
tests/lib.rs
@ -16,7 +16,7 @@
|
||||
|
||||
extern crate magick_rust;
|
||||
|
||||
use magick_rust::{MagickWand, magick_wand_genesis, MetricType, ColorspaceType, FilterType, DitherMethod};
|
||||
use magick_rust::{MagickWand, magick_wand_genesis, MetricType, ColorspaceType, FilterType, DitherMethod, PixelWand, bindings};
|
||||
|
||||
use std::error::Error;
|
||||
use std::fs::File;
|
||||
@ -263,3 +263,37 @@ fn test_color_reduction() {
|
||||
assert_eq!(wand.get_image_width() * wand.get_image_height(),
|
||||
histogram.iter().fold(0, |total_colors, wand| total_colors + wand.get_color_count()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_set_image_background_color() {
|
||||
START.call_once(|| {
|
||||
|
||||
magick_wand_genesis();
|
||||
|
||||
});
|
||||
|
||||
let wand = MagickWand::new();
|
||||
|
||||
assert!(wand.read_image("tests/data/rust.png").is_ok());
|
||||
|
||||
|
||||
let mut pw = PixelWand::new();
|
||||
|
||||
pw.set_color("#0000FF").unwrap();
|
||||
|
||||
|
||||
wand.set_image_background_color(&pw).unwrap();
|
||||
|
||||
|
||||
wand.set_image_alpha_channel(bindings::AlphaChannelOption::RemoveAlphaChannel).unwrap();
|
||||
|
||||
|
||||
let blob = wand.write_image_blob("rgb").unwrap();
|
||||
|
||||
|
||||
assert_eq!(0u8, blob[0]);
|
||||
|
||||
assert_eq!(0u8, blob[1]);
|
||||
|
||||
assert_eq!(255u8, blob[2]);
|
||||
}
|
||||
Reference in New Issue
Block a user