revise gifload again

final polish, hopefully
This commit is contained in:
John Cupitt 2020-07-03 13:31:00 +01:00
parent 7c2c152a74
commit e5bde64b03

View File

@ -116,7 +116,6 @@
#define DISPOSE_PREVIOUS 3 #define DISPOSE_PREVIOUS 3
#endif #endif
#define NO_TRANSPARENT_INDEX -1 #define NO_TRANSPARENT_INDEX -1
#define TRANSPARENT_MASK 0x01 #define TRANSPARENT_MASK 0x01
#define DISPOSE_MASK 0x07 #define DISPOSE_MASK 0x07
@ -893,7 +892,7 @@ vips_foreign_load_gif_render_line( VipsForeignLoadGif *gif,
VipsPel *dst = VIPS_IMAGE_ADDR( gif->scratch, VipsPel *dst = VIPS_IMAGE_ADDR( gif->scratch,
overlap.left, overlap.top ); overlap.left, overlap.top );
guint32 * restrict idst = (guint32 *) dst; guint32 * restrict idst = (guint32 *) dst;
VipsPel * restrict src = line + overlap.left - row.left; VipsPel * restrict src = line + (overlap.left - row.left);
int x; int x;
@ -985,7 +984,7 @@ vips_foreign_load_gif_render( VipsForeignLoadGif *gif )
} }
} }
/* Copy the result to frame, which then is picked up from outside /* Copy the result to frame, ready to be copied to our output.
*/ */
memcpy( VIPS_IMAGE_ADDR( gif->frame, 0, 0 ), memcpy( VIPS_IMAGE_ADDR( gif->frame, 0, 0 ),
VIPS_IMAGE_ADDR( gif->scratch, 0, 0 ), VIPS_IMAGE_ADDR( gif->scratch, 0, 0 ),
@ -1033,13 +1032,14 @@ vips_foreign_load_gif_render( VipsForeignLoadGif *gif )
} }
} }
else if( gif->dispose == DISPOSE_PREVIOUS ) else if( gif->dispose == DISPOSE_PREVIOUS )
/* If this is PREVIOUS, put everything back. /* PREVIOUS means we restore the previous state of the scratch
* area.
*/ */
memcpy( VIPS_IMAGE_ADDR( gif->scratch, 0, 0 ), memcpy( VIPS_IMAGE_ADDR( gif->scratch, 0, 0 ),
VIPS_IMAGE_ADDR( gif->previous, 0, 0 ), VIPS_IMAGE_ADDR( gif->previous, 0, 0 ),
VIPS_IMAGE_SIZEOF_IMAGE( gif->scratch ) ); VIPS_IMAGE_SIZEOF_IMAGE( gif->scratch ) );
/* Reset values, as Graphic Control Extension is optional /* Reset values, as the Graphic Control Extension is optional
*/ */
gif->dispose = DISPOSAL_UNSPECIFIED; gif->dispose = DISPOSAL_UNSPECIFIED;
gif->transparent_index = NO_TRANSPARENT_INDEX; gif->transparent_index = NO_TRANSPARENT_INDEX;
@ -1605,17 +1605,16 @@ vips_foreign_load_gif_source_init( VipsForeignLoadGifSource *source )
* * @page: %gint, page (frame) to read * * @page: %gint, page (frame) to read
* * @n: %gint, load this many pages * * @n: %gint, load this many pages
* *
* Read a GIF file into a VIPS image. * Read a GIF file into a libvips image.
* *
* Use @page to select a page to render, numbering from zero. * Use @page to select a page to render, numbering from zero.
* *
* Use @n to select the number of pages to render. The default is 1. Pages are * Use @n to select the number of pages to render. The default is 1. Pages are
* rendered in a vertical column, with each individual page aligned to the * rendered in a vertical column. Set to -1 to mean "until the end of the
* left. Set to -1 to mean "until the end of the document". Use vips_grid() * document". Use vips_grid() to change page layout.
* to change page layout.
* *
* The whole GIF is rendered into memory on header access. The output image * The output image will be 1, 2, 3 or 4 bands for mono, mono plus
* will be 1, 2, 3 or 4 bands depending on what the reader finds in the file. * transparency, RGB, or RGB plus transparency.
* *
* See also: vips_image_new_from_file(). * See also: vips_image_new_from_file().
* *