From f753f66e9cebf0b69e380dec540e5815b0775257 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 1 Feb 2010 10:58:18 +0000 Subject: [PATCH] im_*join() gtkdoc --- ChangeLog | 1 + libvips/conversion/im_lrjoin.c | 51 ++++++++++++++++++++++------------ libvips/conversion/im_tbjoin.c | 50 +++++++++++++++++++++------------ 3 files changed, 66 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index 25504e2f..72255483 100644 --- a/ChangeLog +++ b/ChangeLog @@ -31,6 +31,7 @@ - im_check*() name rationalisation - finally removed old flood stuff - im_insert*() bandalike and formatalike +- im_*join() bandalike and formatalike 26/11/09 started 7.20.3 - updated en_GB.po translation diff --git a/libvips/conversion/im_lrjoin.c b/libvips/conversion/im_lrjoin.c index c4e11fcf..0af40723 100644 --- a/libvips/conversion/im_lrjoin.c +++ b/libvips/conversion/im_lrjoin.c @@ -1,12 +1,4 @@ -/* @(#) To join two images left right. The resultant image has - * @(#) Xsize = im1.Xsize + im2.Xsize and Ysize the min of im1.Ysize, im2.Ysize - * @(#) Input images should have the same number of Bands and BandFmt - * @(#) - * @(#) Usage: - * @(#) int im_lrjoin( IMAGE *left, IMAGE *right, IMAGE *out) - * @(#) IMAGE *left, *right, *out; - * @(#) - * @(#) +/* im_lrjoin * * Copyright 1990, 1991: Kirk Martinez, N. Dessipris * Author: Kirk Martinez, N. Dessipris @@ -24,6 +16,9 @@ * - rewritten in terms of im_insert() * 14/4/04 * - sets Xoffset / Yoffset + * 1/2/10 + * - gtkdoc + * - cleanups */ /* @@ -66,20 +61,40 @@ #include #endif /*WITH_DMALLOC*/ + +/** + * im_lrjoin: + * @left: image to go on left + * @right: image to go on right + * @out: output image + * + * Join @left and @right together, left-right. If one is taller than the + * other, @out will be has high as the smaller. + * + * If the number of bands differs, one of the images + * must have one band. In this case, an n-band image is formed from the + * one-band image by joining n copies of the one-band image together, and then + * the two n-band images are operated upon. + * + * The two input images are cast up to the smallest common type (see table + * Smallest common format in + * arithmetic). + * + * See also: im_insert(), im_tbjoin(). + * + * Returns: 0 on success, -1 on error + */ int im_lrjoin( IMAGE *left, IMAGE *right, IMAGE *out ) { - IMAGE *t1 = im_open_local( out, "im_lrjoin:1", "p" ); + IMAGE *t1; - /* Paste right and left together. + /* Paste right and left together, trim the bottom edge. */ - if( !t1 || im_insert( left, right, t1, left->Xsize, 0 ) ) - return( -1 ); - - /* Extract the part which the old im_lrjoin() would have made. - */ - if( im_extract_area( t1, out, - 0, 0, t1->Xsize, IM_MIN( left->Ysize, right->Ysize ) ) ) + if( !(t1 = im_open_local( out, "im_lrjoin:1", "p" )) || + im_insert( left, right, t1, left->Xsize, 0 ) || + im_extract_area( t1, out, + 0, 0, t1->Xsize, IM_MIN( left->Ysize, right->Ysize ) ) ) return( -1 ); out->Xoffset = left->Xsize; diff --git a/libvips/conversion/im_tbjoin.c b/libvips/conversion/im_tbjoin.c index 52831b8b..2aecf096 100644 --- a/libvips/conversion/im_tbjoin.c +++ b/libvips/conversion/im_tbjoin.c @@ -1,12 +1,4 @@ -/* @(#) To join two images top bottom. The resultant image has - * @(#) Ysize = im1.Ysize + im2.Ysize and Xsize the min of im1.Xsize, im2.Xsize - * @(#) Input images should have the same number of Bands and BandFmt - * @(#) - * @(#) Usage: - * @(#) int im_tbjoin(top, bottom, out) - * @(#) IMAGE *top, *bottom, *out; - * @(#) - * @(#) +/* im_tbjoin * * Copyright: 1990, 1991 Kirk Martinez, N. Dessipris * Author: Kirk Martinez, N. Dessipris @@ -24,6 +16,9 @@ * - rewritten in terms of im_insert() * 14/4/04 * - sets Xoffset / Yoffset + * 1/2/10 + * - gtkdoc + * - cleanups */ /* @@ -66,20 +61,39 @@ #include #endif /*WITH_DMALLOC*/ +/** + * im_tbjoin: + * @top: image to go on top + * @bottom: image to go on bottom + * @out: output image + * + * Join @top and @bottom together, up-down. If one is wider than the + * other, @out will be has wide as the smaller. + * + * If the number of bands differs, one of the images + * must have one band. In this case, an n-band image is formed from the + * one-band image by joining n copies of the one-band image together, and then + * the two n-band images are operated upon. + * + * The two input images are cast up to the smallest common type (see table + * Smallest common format in + * arithmetic). + * + * See also: im_insert(), im_tbjoin(). + * + * Returns: 0 on success, -1 on error + */ int im_tbjoin( IMAGE *top, IMAGE *bottom, IMAGE *out ) { - IMAGE *t1 = im_open_local( out, "im_tbjoin:1", "p" ); + IMAGE *t1; - /* Paste top and bottom together. + /* Paste top and bottom together, cut off any leftovers. */ - if( !t1 || im_insert( top, bottom, t1, 0, top->Ysize ) ) - return( -1 ); - - /* Extract the part which the old im_tbjoin() would have made. - */ - if( im_extract_area( t1, out, - 0, 0, IM_MIN( top->Xsize, bottom->Xsize ), t1->Ysize ) ) + if( !(t1 = im_open_local( out, "im_tbjoin:1", "p" )) || + im_insert( top, bottom, t1, 0, top->Ysize ) || + im_extract_area( t1, out, + 0, 0, IM_MIN( top->Xsize, bottom->Xsize ), t1->Ysize ) ) return( -1 ); out->Xoffset = 0;