From 247139d11bb4cea3d14bcd41528c658939f7f447 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Sat, 3 Nov 2007 14:18:13 +0000 Subject: [PATCH] stuff --- ChangeLog | 2 +- TODO | 2 + libsrc/conversion/im_vips2tiff.c | 81 +++++++++++++++----------------- libsrc/iofuncs/buffer.c | 5 ++ 4 files changed, 47 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index 21b86f90..346bd02c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,7 @@ - various include cleanups, updated man pages - break im_wbuffer() out to a separate API - use im_wbuffer() to make im_vips2jpeg() compress in the background -- also im_vips2png() +- also im_vips2png(), im_vips2tiff() - new system for propogating progress settings down pipelines unbreaks save feedback in nip2 diff --git a/TODO b/TODO index 90143833..ea5035ec 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,5 @@ +- use im_wbuffer() to loop in im_iterate()? + - talk about new progress system in im_add_eval_callback()? - done jpeg, png ... make others dbl-buf writes too diff --git a/libsrc/conversion/im_vips2tiff.c b/libsrc/conversion/im_vips2tiff.c index d2111af5..cc397395 100644 --- a/libsrc/conversion/im_vips2tiff.c +++ b/libsrc/conversion/im_vips2tiff.c @@ -91,6 +91,8 @@ * 18/7/07 Andrey Kiselev * - remove "b" option on TIFFOpen() * - support TIFFTAG_PREDICTOR types for lzw and deflate compression + * 3/11/07 + * - use im_wbuffer() for background writes */ /* @@ -1037,57 +1039,52 @@ write_tif_tile( TiffWrite *tw ) return( 0 ); } +static int +write_tif_block( REGION *region, Rect *area, void *a, void *b ) +{ + TiffWrite *tw = (TiffWrite *) a; + IMAGE *im = tw->im; + + int y; + + for( y = 0; y < area->height; y++ ) { + PEL *p = (PEL *) IM_REGION_ADDR( region, 0, area->top + y ); + + /* Any repacking necessary. + */ + if( im->Coding == IM_CODING_LABQ ) { + LabQ2LabC( tw->tbuf, p, im->Xsize ); + p = tw->tbuf; + } + else if( im->BandFmt == IM_BANDFMT_SHORT && + im->Type == IM_TYPE_LABS ) { + LabS2Lab16( tw->tbuf, p, im->Xsize ); + p = tw->tbuf; + } + else if( tw->onebit ) { + eightbit2onebit( tw->tbuf, p, im->Xsize ); + p = tw->tbuf; + } + + if( TIFFWriteScanline( tw->tif, p, area->top + y, 0 ) < 0 ) + return( -1 ); + } + + return( 0 ); +} + /* Write as scan-lines. */ static int write_tif_strip( TiffWrite *tw ) { - IMAGE *im = tw->im; - Rect area; - int y, y2; + g_assert( !tw->tbuf ); if( !(tw->tbuf = im_malloc( NULL, TIFFScanlineSize( tw->tif ) )) ) return( -1 ); - /* Set up rect we ask for. - */ - area.left = 0; - area.width = im->Xsize; - - for( y = 0; y < im->Ysize; y += tw->tg->nlines ) { - area.top = y; - area.height = IM_MIN( tw->tg->nlines, im->Ysize - y ); - if( im_prepare_thread( tw->tg, tw->reg, &area ) ) - return( -1 ); - - for( y2 = 0; y2 < area.height; y2++ ) { - PEL *p = (PEL *) IM_REGION_ADDR( tw->reg, 0, y + y2 ); - - /* Any repacking necessary. - */ - if( im->Coding == IM_CODING_LABQ ) { - LabQ2LabC( tw->tbuf, p, im->Xsize ); - p = tw->tbuf; - } - else if( im->BandFmt == IM_BANDFMT_SHORT && - im->Type == IM_TYPE_LABS ) { - LabS2Lab16( tw->tbuf, p, im->Xsize ); - p = tw->tbuf; - } - else if( tw->onebit ) { - eightbit2onebit( tw->tbuf, p, im->Xsize ); - p = tw->tbuf; - } - - /* Write to TIFF! easy. - */ - if( TIFFWriteScanline( tw->tif, p, y + y2, 0 ) < 0 ) { - im_error( "im_vips2tiff", - _( "TIFF write failed" ) ); - return( -1 ); - } - } - } + if( im_wbuffer( tw->tg, write_tif_block, tw, NULL ) ) + return( -1 ); return( 0 ); } diff --git a/libsrc/iofuncs/buffer.c b/libsrc/iofuncs/buffer.c index 15e28224..7837c61a 100644 --- a/libsrc/iofuncs/buffer.c +++ b/libsrc/iofuncs/buffer.c @@ -495,6 +495,11 @@ im__link_break( IMAGE *parent, IMAGE *child ) parent->children = g_slist_remove( parent->children, child ); child->parents = g_slist_remove( child->parents, parent ); + /* Unlink the progress chain. + */ + if( parent->progress && parent->progress == child->progress ) + parent->progress = NULL; + return( NULL ); }