fix non-animated read
This commit is contained in:
parent
d7e8688c35
commit
7071ad79a8
|
@ -108,6 +108,10 @@ typedef struct {
|
||||||
*/
|
*/
|
||||||
int frame_count;
|
int frame_count;
|
||||||
|
|
||||||
|
/* Delay between frames. We don't let this change between frames.
|
||||||
|
*/
|
||||||
|
int delay;
|
||||||
|
|
||||||
/* If we are opening a file object, the fd.
|
/* If we are opening a file object, the fd.
|
||||||
*/
|
*/
|
||||||
int fd;
|
int fd;
|
||||||
|
@ -159,10 +163,14 @@ vips__iswebp( const char *filename )
|
||||||
static int
|
static int
|
||||||
read_free( Read *read )
|
read_free( Read *read )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if( read->frames ) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for( i = 0; i < read->frames->len; i++ )
|
for( i = 0; i < read->frames->len; i++ )
|
||||||
VIPS_UNREF( g_array_index( read->frames, VipsImage *, i ) );
|
VIPS_UNREF( g_array_index(
|
||||||
|
read->frames, VipsImage *, i ) );
|
||||||
|
}
|
||||||
VIPS_FREEF( g_array_unref, read->frames );
|
VIPS_FREEF( g_array_unref, read->frames );
|
||||||
|
|
||||||
VIPS_FREEF( WebPIDelete, read->idec );
|
VIPS_FREEF( WebPIDelete, read->idec );
|
||||||
|
@ -199,6 +207,7 @@ read_new( const char *filename, const void *data, size_t length,
|
||||||
read->page = page;
|
read->page = page;
|
||||||
read->n = n;
|
read->n = n;
|
||||||
read->shrink = shrink;
|
read->shrink = shrink;
|
||||||
|
read->delay = 100;
|
||||||
read->fd = 0;
|
read->fd = 0;
|
||||||
read->idec = NULL;
|
read->idec = NULL;
|
||||||
read->demux = NULL;
|
read->demux = NULL;
|
||||||
|
@ -274,7 +283,8 @@ read_header( Read *read, VipsImage *out )
|
||||||
WebPIterator iter;
|
WebPIterator iter;
|
||||||
|
|
||||||
loop_count = WebPDemuxGetI( read->demux, WEBP_FF_LOOP_COUNT );
|
loop_count = WebPDemuxGetI( read->demux, WEBP_FF_LOOP_COUNT );
|
||||||
read->frame_count = WebPDemuxGetI( read->demux, WEBP_FF_FRAME_COUNT );
|
read->frame_count = WebPDemuxGetI( read->demux,
|
||||||
|
WEBP_FF_FRAME_COUNT );
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf( "webp2vips: animation\n" );
|
printf( "webp2vips: animation\n" );
|
||||||
|
@ -284,8 +294,6 @@ read_header( Read *read, VipsImage *out )
|
||||||
|
|
||||||
vips_image_set_int( out, "gif-loop", loop_count );
|
vips_image_set_int( out, "gif-loop", loop_count );
|
||||||
vips_image_set_int( out, "page-height", read->frame_height );
|
vips_image_set_int( out, "page-height", read->frame_height );
|
||||||
read->frames = g_array_sized_new( FALSE, TRUE,
|
|
||||||
sizeof( void * ), read->frame_count );
|
|
||||||
|
|
||||||
/* We must get the first frame to get the delay.
|
/* We must get the first frame to get the delay.
|
||||||
*/
|
*/
|
||||||
|
@ -307,6 +315,9 @@ read_header( Read *read, VipsImage *out )
|
||||||
read->frame_count = 1;
|
read->frame_count = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
read->frames = g_array_sized_new( FALSE, TRUE,
|
||||||
|
sizeof( void * ), read->frame_count );
|
||||||
|
|
||||||
if( read->width <= 0 ||
|
if( read->width <= 0 ||
|
||||||
read->height <= 0 ) {
|
read->height <= 0 ) {
|
||||||
vips_error( "webp", "%s", _( "bad image dimensions" ) );
|
vips_error( "webp", "%s", _( "bad image dimensions" ) );
|
||||||
|
|
Loading…
Reference in New Issue