diff options
Diffstat (limited to 'third_party/skcms/src/Transform.c')
-rw-r--r-- | third_party/skcms/src/Transform.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/third_party/skcms/src/Transform.c b/third_party/skcms/src/Transform.c index f07c5e7ba4..ebfd0cef5b 100644 --- a/third_party/skcms/src/Transform.c +++ b/third_party/skcms/src/Transform.c @@ -354,6 +354,9 @@ static OpAndArg select_curve_op(const skcms_Curve* curve, int channel) { static size_t bytes_per_pixel(skcms_PixelFormat fmt) { switch (fmt >> 1) { // ignore rgb/bgr + case skcms_PixelFormat_A_8 >> 1: return 1; + case skcms_PixelFormat_G_8 >> 1: return 1; + case skcms_PixelFormat_ABGR_4444 >> 1: return 2; case skcms_PixelFormat_RGB_565 >> 1: return 2; case skcms_PixelFormat_RGB_888 >> 1: return 3; case skcms_PixelFormat_RGBA_8888 >> 1: return 4; @@ -430,6 +433,9 @@ bool skcms_Transform(const void* src, switch (srcFmt >> 1) { default: return false; + case skcms_PixelFormat_A_8 >> 1: *ops++ = Op_load_a8; break; + case skcms_PixelFormat_G_8 >> 1: *ops++ = Op_load_g8; break; + case skcms_PixelFormat_ABGR_4444 >> 1: *ops++ = Op_load_4444; break; case skcms_PixelFormat_RGB_565 >> 1: *ops++ = Op_load_565; break; case skcms_PixelFormat_RGB_888 >> 1: *ops++ = Op_load_888; break; case skcms_PixelFormat_RGBA_8888 >> 1: *ops++ = Op_load_8888; break; @@ -444,6 +450,14 @@ bool skcms_Transform(const void* src, if (srcFmt & 1) { *ops++ = Op_swap_rb; } + skcms_ICCProfile gray_dst_profile; + if ((dstFmt >> 1) == (skcms_PixelFormat_G_8 >> 1)) { + // When transforming to gray, stop at XYZ (by setting toXYZ to identity), then transform + // luminance (Y) by the destination transfer function. + gray_dst_profile = *dstProfile; + skcms_SetXYZD50(&gray_dst_profile, &skcms_XYZD50_profile()->toXYZD50); + dstProfile = &gray_dst_profile; + } if (srcProfile->data_color_space == skcms_Signature_CMYK) { // Photoshop creates CMYK images as inverse CMYK. @@ -585,6 +599,9 @@ bool skcms_Transform(const void* src, } switch (dstFmt >> 1) { default: return false; + case skcms_PixelFormat_A_8 >> 1: *ops++ = Op_store_a8; break; + case skcms_PixelFormat_G_8 >> 1: *ops++ = Op_store_g8; break; + case skcms_PixelFormat_ABGR_4444 >> 1: *ops++ = Op_store_4444; break; case skcms_PixelFormat_RGB_565 >> 1: *ops++ = Op_store_565; break; case skcms_PixelFormat_RGB_888 >> 1: *ops++ = Op_store_888; break; case skcms_PixelFormat_RGBA_8888 >> 1: *ops++ = Op_store_8888; break; |