From e496df598be762920d098bf73ae064deda76175f Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Tue, 1 May 2018 15:50:48 +0100 Subject: [PATCH] working! --- ChangeLog | 1 + libvips/conversion/Makefile.am | 1 + libvips/conversion/conversion.c | 2 ++ libvips/conversion/transpose3d.c | 28 +++++++++++++++++----------- libvips/include/vips/conversion.h | 2 ++ 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index bc8aefff..e6dae0a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,7 @@ chrominance subsampling. - tiffload, pdfload, magickload set VIPS_META_N_PAGES "n-pages" metadata item - add fontfile option to vips_text() [fangqiao] +- add vips_transpose3d() -- swap major dimensions in a volumetric image 12/3/18 started 8.6.4 - better fitting of fonts with overhanging edges [AdriĆ ] diff --git a/libvips/conversion/Makefile.am b/libvips/conversion/Makefile.am index 55b42c5f..95b8d4fc 100644 --- a/libvips/conversion/Makefile.am +++ b/libvips/conversion/Makefile.am @@ -1,6 +1,7 @@ noinst_LTLIBRARIES = libconversion.la libconversion_la_SOURCES = \ + transpose3d.c \ composite.cpp \ smartcrop.c \ conversion.c \ diff --git a/libvips/conversion/conversion.c b/libvips/conversion/conversion.c index d8f993b3..b6cdd9fc 100644 --- a/libvips/conversion/conversion.c +++ b/libvips/conversion/conversion.c @@ -377,6 +377,7 @@ vips_conversion_operation_init( void ) extern GType vips_bandbool_get_type( void ); extern GType vips_gaussnoise_get_type( void ); extern GType vips_grid_get_type( void ); + extern GType vips_transpose3d_get_type( void ); extern GType vips_scale_get_type( void ); extern GType vips_wrap_get_type( void ); extern GType vips_zoom_get_type( void ); @@ -427,6 +428,7 @@ vips_conversion_operation_init( void ) vips_bandbool_get_type(); vips_gaussnoise_get_type(); vips_grid_get_type(); + vips_transpose3d_get_type(); vips_scale_get_type(); vips_wrap_get_type(); vips_zoom_get_type(); diff --git a/libvips/conversion/transpose3d.c b/libvips/conversion/transpose3d.c index 19d79fb4..37cd3282 100644 --- a/libvips/conversion/transpose3d.c +++ b/libvips/conversion/transpose3d.c @@ -1,7 +1,7 @@ /* vips_transpose3d * * 30/4/18 - * - from grid.c as a class + * - from grid.c */ /* @@ -49,7 +49,7 @@ typedef struct _VipsTranspose3d { VipsImage *in; - int tile_height; + int page_height; } VipsTranspose3d; @@ -68,7 +68,7 @@ vips_transpose3d_gen( VipsRegion *or, void *vseq, void *a, void *b, int output_page_height = in->Ysize / transpose3d->page_height; - int x, y; + int y; VipsRect tile; tile = *r; @@ -93,13 +93,13 @@ vips_transpose3d_gen( VipsRegion *or, void *vseq, void *a, void *b, /* y of input line. */ - yi = yip + yop; + int yi = yip + yop; - tile.top = yo; + tile.top = yi; /* Render into or. */ - if( vips_region_prepare_to( ir, or, &tile, tile.left, yi ) + if( vips_region_prepare_to( ir, or, &tile, tile.left, yo ) ) return( -1 ); } @@ -197,12 +197,18 @@ vips_transpose3d_init( VipsTranspose3d *transpose3d ) * Transpose a volumetric image. * * Volumetric images are very tall, thin images, with the metadata item - * `page-height` set to the height of each sub-image. + * #VIPS_META_PAGE_HEIGHT set to the height of each sub-image. * - * This operation swaps two dimensions around so that one row in each input - * page becomes one row in a single output page. + * This operation swaps the two major dimensions, so that page N in the + * output contains the Nth scanline, in order, from each input page. * - * See also: vips_transpose3d(). + * You can override the #VIPS_META_PAGE_HEIGHT metadata item with the optional + * @page_height parameter. + * + * #VIPS_META_PAGE_HEIGHT in the output image is the number of pages in the + * input image. + * + * See also: vips_grid(). * * Returns: 0 on success, -1 on error */ @@ -212,7 +218,7 @@ vips_transpose3d( VipsImage *in, VipsImage **out, ... ) va_list ap; int result; - va_start( ap, down ); + va_start( ap, out ); result = vips_call_split( "transpose3d", ap, in, out ); va_end( ap ); diff --git a/libvips/include/vips/conversion.h b/libvips/include/vips/conversion.h index a7db19c7..a466182d 100644 --- a/libvips/include/vips/conversion.h +++ b/libvips/include/vips/conversion.h @@ -175,6 +175,8 @@ int vips_replicate( VipsImage *in, VipsImage **out, int across, int down, ... ) int vips_grid( VipsImage *in, VipsImage **out, int tile_height, int across, int down, ... ) __attribute__((sentinel)); +int vips_transpose3d( VipsImage *in, VipsImage **out, ... ) + __attribute__((sentinel)); int vips_wrap( VipsImage *in, VipsImage **out, ... ) __attribute__((sentinel)); int vips_rot( VipsImage *in, VipsImage **out, VipsAngle angle, ... )