Skip to content

Commit d442d46

Browse files
authored
Merge pull request rust-skia#1139 from talonvoice/icc-colorspace
add ColorSpace::new_icc()
2 parents 30f7f32 + c4d7328 commit d442d46

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

skia-bindings/src/bindings.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,14 @@ extern "C" bool C_SkColorSpace_unique(const SkColorSpace* self) {
981981
return self->unique();
982982
}
983983

984+
extern "C" SkColorSpace* C_SkColorSpace_MakeICC(const void* buffer, size_t size) {
985+
skcms_ICCProfile profile;
986+
if (skcms_Parse(buffer, size, &profile)) {
987+
return SkColorSpace::Make(profile).release();
988+
}
989+
return nullptr;
990+
}
991+
984992
extern "C" SkColorSpace* C_SkColorSpace_MakeSRGB() {
985993
return SkColorSpace::MakeSRGB().release();
986994
}

skia-safe/src/core/color_space.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,10 @@ impl ColorSpace {
385385
Self::from_ptr(unsafe { sb::C_SkColorSpace_MakeSRGBLinear() }).unwrap()
386386
}
387387

388+
pub fn new_icc(data: &[u8]) -> Option<Self> {
389+
Self::from_ptr(unsafe { sb::C_SkColorSpace_MakeICC(data.as_ptr() as _, data.len()) })
390+
}
391+
388392
// TODO: makeRGB
389393

390394
pub fn new_cicp(

0 commit comments

Comments
 (0)