make skip_blanks an int
so you can adjust the threshold
This commit is contained in:
parent
51dbf607dd
commit
d1989e4c94
@ -450,7 +450,7 @@ struct _VipsForeignSaveDz {
|
||||
VipsForeignDzContainer container;
|
||||
int compression;
|
||||
VipsRegionShrink region_shrink;
|
||||
gboolean skip_blanks;
|
||||
int skip_blanks;
|
||||
|
||||
/* Tile and overlap geometry. The members above are the parameters we
|
||||
* accept, this next set are the derived values which are actually
|
||||
@ -1047,14 +1047,14 @@ tile_name( Layer *layer, int x, int y )
|
||||
return( out );
|
||||
}
|
||||
|
||||
/* Test for tile equal to background colour. In google maps mode, we skip
|
||||
* blank background tiles.
|
||||
/* Test for tile nearly equal to background colour. In google maps mode, we
|
||||
* skip blank background tiles.
|
||||
*
|
||||
* Don't use exactly equality, since compression artefacts or noise can upset
|
||||
* Don't use exactly equality since compression artefacts or noise can upset
|
||||
* this.
|
||||
*/
|
||||
static gboolean
|
||||
tile_equal( VipsImage *image, VipsPel * restrict ink )
|
||||
tile_equal( VipsImage *image, int threshold, VipsPel * restrict ink )
|
||||
{
|
||||
const int bytes = VIPS_IMAGE_SIZEOF_PEL( image );
|
||||
|
||||
@ -1080,7 +1080,7 @@ tile_equal( VipsImage *image, VipsPel * restrict ink )
|
||||
|
||||
for( x = 0; x < image->Xsize; x++ ) {
|
||||
for( b = 0; b < bytes; b++ )
|
||||
if( VIPS_ABS( p[b] - ink[b] ) > 5 ) {
|
||||
if( VIPS_ABS( p[b] - ink[b] ) > threshold ) {
|
||||
g_object_unref( region );
|
||||
return( FALSE );
|
||||
}
|
||||
@ -1169,8 +1169,8 @@ strip_work( VipsThreadState *state, void *a )
|
||||
state->pos.width, state->pos.height, NULL ) )
|
||||
return( -1 );
|
||||
|
||||
if( dz->skip_blanks &&
|
||||
tile_equal( x, dz->ink ) ) {
|
||||
if( dz->skip_blanks > 0 &&
|
||||
tile_equal( x, dz->skip_blanks, dz->ink ) ) {
|
||||
g_object_unref( x );
|
||||
|
||||
#ifdef DEBUG_VERBOSE
|
||||
@ -1631,11 +1631,11 @@ vips_foreign_save_dz_build( VipsObject *object )
|
||||
dz->tile_size = 256;
|
||||
}
|
||||
|
||||
/* skip_blanks defaults TRUE in google mode.
|
||||
/* skip_blanks defaults to 5 in google mode.
|
||||
*/
|
||||
if( dz->layout == VIPS_FOREIGN_DZ_LAYOUT_GOOGLE &&
|
||||
!vips_object_argument_isset( object, "skip_blanks" ) )
|
||||
dz->skip_blanks = TRUE;
|
||||
dz->skip_blanks = 5;
|
||||
|
||||
/* Our tile layout.
|
||||
*/
|
||||
@ -1697,7 +1697,7 @@ vips_foreign_save_dz_build( VipsObject *object )
|
||||
|
||||
/* We use ink to check for blank tiles.
|
||||
*/
|
||||
if( dz->skip_blanks ) {
|
||||
if( dz->skip_blanks > 0 ) {
|
||||
if( !(dz->ink = vips__vector_to_ink(
|
||||
class->nickname, save->ready,
|
||||
VIPS_AREA( save->background )->data, NULL,
|
||||
@ -2110,12 +2110,12 @@ vips_foreign_save_dz_class_init( VipsForeignSaveDzClass *class )
|
||||
G_STRUCT_OFFSET( VipsForeignSaveDz, region_shrink ),
|
||||
VIPS_TYPE_REGION_SHRINK, VIPS_REGION_SHRINK_MEAN );
|
||||
|
||||
VIPS_ARG_BOOL( class, "skip_blanks", 19,
|
||||
VIPS_ARG_INT( class, "skip_blanks", 19,
|
||||
_( "Skip blanks" ),
|
||||
_( "Skip tiles which are nearly equal to the background" ),
|
||||
VIPS_ARGUMENT_OPTIONAL_INPUT,
|
||||
G_STRUCT_OFFSET( VipsForeignSaveDz, skip_blanks ),
|
||||
FALSE );
|
||||
0, 65535, 5 );
|
||||
|
||||
/* How annoying. We stupidly had these in earlier versions.
|
||||
*/
|
||||
@ -2353,7 +2353,7 @@ vips_foreign_save_dz_buffer_init( VipsForeignSaveDzBuffer *buffer )
|
||||
* * @properties: %gboolean write a properties file
|
||||
* * @compression: %gint zip deflate compression level
|
||||
* * @region_shrink: #VipsRegionShrink How to shrink each 2x2 region
|
||||
* * @skip_blanks: %gboolean Skip tiles which are equal to the background
|
||||
* * @skip_blanks: %gint Skip tiles which are nearly equal to the background
|
||||
*
|
||||
* Save an image as a set of tiles at various resolutions. By default dzsave
|
||||
* uses DeepZoom layout -- use @layout to pick other conventions.
|
||||
@ -2401,9 +2401,10 @@ vips_foreign_save_dz_buffer_init( VipsForeignSaveDzBuffer *buffer )
|
||||
* region. This defaults to using the average of the 4 input pixels but you can
|
||||
* also use the median in cases where you want to preserve the range of values.
|
||||
*
|
||||
* If you set @skip_blanks, tiles which are almost equal to the background are
|
||||
* skipped. This can save a lot of space for some image types. This option
|
||||
* defaults %TRUE in Google layout mode.
|
||||
* If you set @skip_blanks to a value greater than zero, tiles which are
|
||||
* all within that many pixel values to the background are skipped. This can
|
||||
* save a lot of space for some image types. This option defaults to 5 in
|
||||
* Google layout mode, 0 otherwise.
|
||||
*
|
||||
* See also: vips_tiffsave().
|
||||
*
|
||||
@ -2444,7 +2445,7 @@ vips_dzsave( VipsImage *in, const char *name, ... )
|
||||
* * @properties: %gboolean write a properties file
|
||||
* * @compression: %gint zip deflate compression level
|
||||
* * @region_shrink: #VipsRegionShrink How to shrink each 2x2 region.
|
||||
* * @skip_blanks: %gboolean Skip tiles which are equal to the background
|
||||
* * @skip_blanks: %gint Skip tiles which are nearly equal to the background
|
||||
*
|
||||
* As vips_dzsave(), but save to a memory buffer.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user