tiny cleanups for png write
This commit is contained in:
parent
a7185b0973
commit
65cab8db7d
@ -783,12 +783,15 @@ typedef struct {
|
||||
} Write;
|
||||
|
||||
static void
|
||||
write_finish( Write *write )
|
||||
write_destroy( Write *write )
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf( "write_destroy: %p\n", write );
|
||||
#endif /*DEBUG*/
|
||||
|
||||
VIPS_UNREF( write->memory );
|
||||
if( write->target )
|
||||
vips_target_finish( write->target );
|
||||
VIPS_UNREF( write->target );
|
||||
if( write->pPng )
|
||||
png_destroy_write_struct( &write->pPng, &write->pInfo );
|
||||
VIPS_FREE( write->row_pointer );
|
||||
@ -811,18 +814,19 @@ write_new( VipsImage *in, VipsTarget *target )
|
||||
|
||||
if( !(write = VIPS_NEW( NULL, Write )) )
|
||||
return( NULL );
|
||||
memset( write, 0, sizeof( Write ) );
|
||||
write->in = in;
|
||||
write->memory = NULL;
|
||||
write->target = target;
|
||||
g_object_ref( target );
|
||||
|
||||
#ifdef DEBUG
|
||||
printf( "write_new: %p\n", write );
|
||||
#endif /*DEBUG*/
|
||||
|
||||
if( !(write->row_pointer = VIPS_ARRAY( NULL, in->Ysize, png_bytep )) )
|
||||
return( NULL );
|
||||
if( !(write->pPng = png_create_write_struct(
|
||||
PNG_LIBPNG_VER_STRING, NULL,
|
||||
user_error_function, user_warning_function )) ) {
|
||||
write_finish( write );
|
||||
write_destroy( write );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
@ -840,12 +844,12 @@ write_new( VipsImage *in, VipsTarget *target )
|
||||
/* Catch PNG errors from png_create_info_struct().
|
||||
*/
|
||||
if( setjmp( png_jmpbuf( write->pPng ) ) ) {
|
||||
write_finish( write );
|
||||
write_destroy( write );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
if( !(write->pInfo = png_create_info_struct( write->pPng )) ) {
|
||||
write_finish( write );
|
||||
write_destroy( write );
|
||||
return( NULL );
|
||||
}
|
||||
|
||||
@ -1196,8 +1200,6 @@ write_vips( Write *write,
|
||||
|
||||
png_write_end( write->pPng, write->pInfo );
|
||||
|
||||
vips_target_finish( write->target );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
@ -1216,13 +1218,13 @@ vips__png_write_target( VipsImage *in, VipsTarget *target,
|
||||
if( write_vips( write,
|
||||
compression, interlace, profile, filter, strip, palette,
|
||||
Q, dither, bitdepth ) ) {
|
||||
write_finish( write );
|
||||
write_destroy( write );
|
||||
vips_error( "vips2png", _( "unable to write to target %s" ),
|
||||
vips_connection_nick( VIPS_CONNECTION( target ) ) );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
write_finish( write );
|
||||
write_destroy( write );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user