feat(palette-extract): 补 bmp 解码器(复审 r1 p2-2,定案加)
M73 的 Windows 壁纸探测只读注册表/.theme 里的路径,不筛扩展名,.bmp 壁纸真会出现; image 的 bmp 是独立 feature 且无额外传递依赖(bmp = []),代价≈0。 - features 加 "bmp",Cargo.toml 与 lib.rs 注释的口径对齐(原来注释说支持 bmp 但没开) - 新增 bmp_is_supported(真编一张 BMP 再解码取色)
This commit is contained in:
1 parent
2ce394fbfc
commit
579f3ae271
3 files changed
+29
-5
No files matched your search
@@ -61,6 +61,22 @@ fn extension_is_ignored_and_format_is_sniffed() {
|
||||
assert_eq!((decoded.width(), decoded.height()), (16, 16));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bmp_is_supported() {
|
||||
// M73 的 Windows 壁纸探测不筛扩展名,`.bmp` 壁纸会真的出现在取色路径上。
|
||||
// BMP 编码不是无损于色的(24 bit 存 RGB,这里是 32 bit Rgba),所以逐通道比对即可。
|
||||
let mut bytes = Cursor::new(Vec::new());
|
||||
DynamicImage::ImageRgba8(solid_image(32, 32, [0xB2, 0x3A, 0x48]))
|
||||
.write_to(&mut bytes, ImageFormat::Bmp)
|
||||
.expect("BMP 编码应当成功");
|
||||
let seed = seed_from_bytes(&bytes.into_inner()).expect("BMP 应当能解码并取色");
|
||||
assert_eq!(
|
||||
seed.color,
|
||||
unlucky_design::color::Color::rgb(0xB2, 0x3A, 0x48)
|
||||
);
|
||||
assert!(seed.chroma > 8.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn garbage_bytes_fail_and_map_to_undecodable() {
|
||||
let loaded = decode_bytes(b"this is definitely not an image");
|
||||
|
||||
Reference in new issue
Block a user