diff --git a/libvips/conversion/im_mask2vips.c b/libvips/conversion/im_mask2vips.c index 85154ec6..2f1978de 100644 --- a/libvips/conversion/im_mask2vips.c +++ b/libvips/conversion/im_mask2vips.c @@ -1,14 +1,12 @@ -/* @(#) Function to write a DOUBLEMASK to an IMAGE. - * @(#) - * @(#) int - * @(#) im_mask2vips( DOUBLEMASK *in, IMAGE *out ) - * @(#) - * @(#) The function returns -1 on error and 0 on success +/* im_mask2vips + * * Author: J.Cupitt * Written on: 6/6/94 * Modified on: * 7/10/94 JC * - new IM_ARRAY() + * 1/2/10 + * - gtkdoc */ /* @@ -51,6 +49,17 @@ #include #endif /*WITH_DMALLOC*/ +/** + * im_mask2vips: + * @in: input mask + * @out output image + * + * Write a one-band, #IM_BANDFMT_DOUBLE image to @out based on mask @in. + * + * See also: im_vips2mask(). + * + * Returns: 0 on success, -1 on error + */ int im_mask2vips( DOUBLEMASK *in, IMAGE *out ) { diff --git a/libvips/conversion/im_vips2mask.c b/libvips/conversion/im_vips2mask.c index 06dc86ce..a657bc4f 100644 --- a/libvips/conversion/im_vips2mask.c +++ b/libvips/conversion/im_vips2mask.c @@ -1,10 +1,5 @@ -/* @(#) Function to write an IMAGE to a DOUBLEMASK. One band IM_BANDFMT_DOUBLE - * @(#) images, or n-band by 1 pixel double images. - * @(#) - * @(#) DOUBLEMASK * - * @(#) im_vips2mask( IMAGE *in, char *out ) - * @(#) - * @(#) The function returns NULL on error and a new DOUBLEMASK on success +/* im_vips2mask + * * Author: J.Cupitt * Written on: 6/6/94 * Modified on: @@ -14,6 +9,8 @@ * 23/2/07 * - oop, broken for nx1 m-band images * - now casts to double for you + * 1/2/10 + * - gtkdoc */ /* @@ -55,6 +52,24 @@ #include #endif /*WITH_DMALLOC*/ +/** + * im_vips2mask: + * @in: input image + * @outname: name for output mask + * + * Make a mask from an image. All images are cast to #IM_BANDFMT_DOUBLE + * before processing. There are two cases for handling bands: + * + * If the image has a single band, im_vips2mask() will write a mask the same + * size as the image. + * + * If the image has more than one band, it must be one pixel high or wide. In + * this case the output mask uses that axis to represent band values. + * + * See also: im_mask2vips(), im_measure(). + * + * Returns: a #DOUBLEMASK with @outname set as the name, or NULL on error + */ DOUBLEMASK * im_vips2mask( IMAGE *in, const char *outname ) { @@ -80,12 +95,10 @@ im_vips2mask( IMAGE *in, const char *outname ) /* Check the image. */ - if( im_incheck( in ) ) + if( im_incheck( in ) || + im_check_uncoded( "im_vips2mask", in ) ) return( NULL ); - if( in->Coding != IM_CODING_NONE ) { - im_error( "im_vips2mask", "%s", _( "uncoded images only" ) ); - return( NULL ); - } + if( in->Bands == 1 ) { width = in->Xsize; height = in->Ysize;