From 01bd7cad04a0d8704a85fd105143338aa9f9375d Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Wed, 10 Sep 2014 09:37:13 +0100 Subject: [PATCH] support GRAY as an input and output ICC space see https://github.com/jcupitt/libvips/issues/176 --- ChangeLog | 2 ++ libvips/colour/icc_transform.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index e3d2d5c5..d9f8fa9a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 8/9/14 started 7.40.9 - support jfif resunit "none" +- support GRAY as an input and output ICC space +- fix a read loop with setjmp() in png read, if the png file is broken 8/9/14 started 7.40.8 - fix configure on rhel6 [Lovell] diff --git a/libvips/colour/icc_transform.c b/libvips/colour/icc_transform.c index cc677105..493fafa5 100644 --- a/libvips/colour/icc_transform.c +++ b/libvips/colour/icc_transform.c @@ -26,6 +26,8 @@ * - import and export would segv on very wide images * 12/11/13 * - support XYZ as an alternative PCS + * 10/9/14 + * - support GRAY as an input and output space */ /* @@ -245,6 +247,16 @@ vips_icc_build( VipsObject *object ) TYPE_RGB_16 : TYPE_RGB_8; break; + case cmsSigGrayData: + code->input_bands = 1; + code->input_format = + code->in->BandFmt == VIPS_FORMAT_USHORT ? + VIPS_FORMAT_USHORT : VIPS_FORMAT_UCHAR; + icc->in_icc_format = + code->in->BandFmt == VIPS_FORMAT_USHORT ? + TYPE_GRAY_16 : TYPE_GRAY_8; + break; + case cmsSigCmykData: code->input_bands = 4; code->input_format = @@ -266,8 +278,6 @@ vips_icc_build( VipsObject *object ) case cmsSigXYZData: code->input_bands = 3; code->input_format = VIPS_FORMAT_FLOAT; - code->input_interpretation = - VIPS_INTERPRETATION_XYZ; icc->in_icc_format = TYPE_XYZ_16; break; @@ -295,6 +305,20 @@ vips_icc_build( VipsObject *object ) TYPE_RGB_16 : TYPE_RGB_8; break; + case cmsSigGrayData: + colour->interpretation = + icc->depth == 8 ? + VIPS_INTERPRETATION_B_W : + VIPS_INTERPRETATION_GREY16; + colour->format = + icc->depth == 8 ? + VIPS_FORMAT_UCHAR : VIPS_FORMAT_USHORT; + colour->bands = 1; + icc->out_icc_format = + icc->depth == 16 ? + TYPE_GRAY_16 : TYPE_GRAY_8; + break; + case cmsSigCmykData: colour->interpretation = VIPS_INTERPRETATION_CMYK; colour->format =