Skip to content

Commit e1575e6

Browse files
Support 32-bit floating-point colors in tests (#18)
1 parent 9ea68fe commit e1575e6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/reference.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use image::{ColorType, DynamicImage};
12
use walkdir::WalkDir;
23

34
#[test]
@@ -10,7 +11,7 @@ fn test_decoding() {
1011
continue;
1112
}
1213

13-
let img = image::open(entry.path()).unwrap();
14+
let img = to_png_compatible_color_type(image::open(entry.path()).unwrap());
1415
let reference = image::open(entry.path().with_extension("png")).unwrap();
1516

1617
assert_eq!(
@@ -21,3 +22,12 @@ fn test_decoding() {
2122
);
2223
}
2324
}
25+
26+
/// PNG doesn't support 32-bit float color types, so convert them to 16-bit.
27+
fn to_png_compatible_color_type(image: DynamicImage) -> DynamicImage {
28+
match image.color() {
29+
ColorType::Rgb32F => image.to_rgb16().into(),
30+
ColorType::Rgba32F => image.to_rgba16().into(),
31+
_ => image,
32+
}
33+
}

0 commit comments

Comments
 (0)