Beispiel #1
0
int
vips__png_write_buf( VipsImage *in, 
	void **obuf, size_t *olen, int compression, int interlace,
	const char *profile, VipsForeignPngFilter filter, gboolean strip )
{
	Write *write;

	if( !(write = write_new( in )) ) 
		return( -1 );

	png_set_write_fn( write->pPng, write, user_write_data, NULL );

	/* Convert it!
	 */
	if( write_vips( write, 
		compression, interlace, profile, filter, strip ) ) {
		vips_error( "vips2png", 
			"%s", _( "unable to write to buffer" ) );
	      
		return( -1 );
	}

	*obuf = write->buf;
	write->buf = NULL;
	if( olen )
		*olen = write->len;

	write_finish( write );

	return( 0 );
}
Beispiel #2
0
int
vips__png_write_buf( VipsImage *in, 
	void **obuf, size_t *olen, int compression, int interlace,
	const char *profile, VipsForeignPngFilter filter, gboolean strip,
	gboolean palette, int colours, int Q, double dither )
{
	Write *write;

	if( !(write = write_new( in )) ) 
		return( -1 );

	png_set_write_fn( write->pPng, write, user_write_data, NULL );

	/* Convert it!
	 */
	if( write_vips( write, 
		compression, interlace, profile, filter, strip, palette,
		colours, Q, dither ) ) {
		vips_error( "vips2png", 
			"%s", _( "unable to write to buffer" ) );

		return( -1 );
	}

	*obuf = vips_dbuf_steal( &write->dbuf, olen );

	write_finish( write );

	return( 0 );
}
Beispiel #3
0
int
vips__png_write( VipsImage *in, const char *filename, 
	int compress, int interlace, const char *profile,
	VipsForeignPngFilter filter, gboolean strip,
	gboolean palette, int colours, int Q, double dither )
{
	Write *write;

#ifdef DEBUG
	printf( "vips__png_write: writing \"%s\"\n", filename );
#endif /*DEBUG*/

	if( !(write = write_new( in )) )
		return( -1 );

	/* Make output.
	 */
        if( !(write->fp = vips__file_open_write( filename, FALSE )) ) 
		return( -1 );
	png_init_io( write->pPng, write->fp );

	/* Convert it!
	 */
	if( write_vips( write, 
		compress, interlace, profile, filter, strip, palette,
		colours, Q, dither ) ) {
		vips_error( "vips2png", 
			_( "unable to write \"%s\"" ), filename );

		return( -1 );
	}

	write_finish( write );

#ifdef DEBUG
	printf( "vips__png_write: done\n" ); 
#endif /*DEBUG*/

	return( 0 );
}
Beispiel #4
0
 void write_run()
 {
   uint32_t llen;
   char* p;
   while (1)
   {
     if (m_close)/*是否被关闭*/
     {
       m_write_close = true;
       return;
     }
     p = write_start(llen);
     if (m_write_fun(p, llen))
     {
       write_finish(llen);
     }
     else
     {
       break;
     }
   }
 }
Beispiel #5
0
int
vips__png_write( VipsImage *in, const char *filename, 
	int compress, int interlace )
{
	Write *write;

#ifdef DEBUG
	printf( "vips__png_write: writing \"%s\"\n", filename );
#endif /*DEBUG*/

	if( !(write = write_new( in )) )
		return( -1 );

	/* Make output.
	 */
        if( !(write->fp = vips__file_open_write( filename, FALSE )) ) 
		return( -1 );
	png_init_io( write->pPng, write->fp );

	/* Convert it!
	 */
	if( write_vips( write, compress, interlace ) ) {
		vips_error( "vips2png", 
			_( "unable to write \"%s\"" ), filename );

		return( -1 );
	}

	write_finish( write );

#ifdef DEBUG
	printf( "vips__png_write: done\n" ); 
#endif /*DEBUG*/

	return( 0 );
}
Beispiel #6
0
static void
write_destroy( VipsImage *out, Write *write )
{
	write_finish( write ); 
}