"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/gd_webp.c" between
libgd-2.3.2.tar.gz and libgd-2.3.3.tar.gz

About: LibGD is a library for the dynamic creation of images by programmers (PNG, JPEG, GIF, WebP, XPM, BMP support).

gd_webp.c  (libgd-2.3.2):gd_webp.c  (libgd-2.3.3)
skipping to change at line 106 skipping to change at line 106
Function: gdImageCreateFromWebpCtx Function: gdImageCreateFromWebpCtx
See <gdImageCreateFromWebp>. See <gdImageCreateFromWebp>.
*/ */
BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpCtx (gdIOCtx * infile) BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpCtx (gdIOCtx * infile)
{ {
int width, height; int width, height;
uint8_t *filedata = NULL; uint8_t *filedata = NULL;
uint8_t *argb = NULL; uint8_t *argb = NULL;
unsigned char *read, *temp; unsigned char *read, *temp;
size_t size = 0, n; ssize_t size = 0, n;
gdImagePtr im; gdImagePtr im;
int x, y; int x, y;
uint8_t *p; uint8_t *p;
do { do {
temp = gdRealloc(filedata, size+GD_WEBP_ALLOC_STEP); temp = gdRealloc(filedata, size+GD_WEBP_ALLOC_STEP);
if (temp) { if (temp) {
filedata = temp; filedata = temp;
read = temp + size; read = temp + size;
} else { } else {
skipping to change at line 217 skipping to change at line 217
a = 0; a = 0;
} else { } else {
a = 255 - ((a << 1) + (a >> 6)); a = 255 - ((a << 1) + (a >> 6));
} }
*(p++) = gdTrueColorGetRed(c); *(p++) = gdTrueColorGetRed(c);
*(p++) = gdTrueColorGetGreen(c); *(p++) = gdTrueColorGetGreen(c);
*(p++) = gdTrueColorGetBlue(c); *(p++) = gdTrueColorGetBlue(c);
*(p++) = a; *(p++) = a;
} }
} }
out_size = WebPEncodeRGBA(argb, gdImageSX(im), gdImageSY(im), gdImageSX(i if (quality >= gdWebpLossless) {
m) * 4, quality, &out); out_size = WebPEncodeLosslessRGBA(argb, gdImageSX(im), gdImageSY(
im), gdImageSX(im) * 4, &out);
} else {
out_size = WebPEncodeRGBA(argb, gdImageSX(im), gdImageSY(im), gdI
mageSX(im) * 4, quality, &out);
}
if (out_size == 0) { if (out_size == 0) {
gd_error("gd-webp encoding failed"); gd_error("gd-webp encoding failed");
ret = 1; ret = 1;
goto freeargb; goto freeargb;
} }
gdPutBuf(out, out_size, outfile);
int res = gdPutBuf(out, out_size, outfile);
free(out); free(out);
if (res != out_size) {
gd_error("gd-webp write error\n");
ret = 1;
}
freeargb: freeargb:
gdFree(argb); gdFree(argb);
return ret; return ret;
} }
/* /*
Function: gdImageWebpCtx Function: gdImageWebpCtx
skipping to change at line 268 skipping to change at line 277
all versions of Windows, it is important to use "wb" as opposed to all versions of Windows, it is important to use "wb" as opposed to
simply "w" as the mode when opening the file, and under Unix there simply "w" as the mode when opening the file, and under Unix there
is no penalty for doing so. <gdImageWebpEx> does not close the file; is no penalty for doing so. <gdImageWebpEx> does not close the file;
your code must do so. your code must do so.
If _quality_ is -1, a reasonable quality value (which should yield a If _quality_ is -1, a reasonable quality value (which should yield a
good general quality / size tradeoff for most situations) is used. Otherw ise good general quality / size tradeoff for most situations) is used. Otherw ise
_quality_ should be a value in the range 0-100, higher quality values _quality_ should be a value in the range 0-100, higher quality values
usually implying both higher quality and larger image sizes. usually implying both higher quality and larger image sizes.
If _quality_ is greater than or equal to <gdWebpLossless> then the image
will be written in the lossless WebP format.
Variants: Variants:
<gdImageWebpCtx> stores the image using a <gdIOCtx> struct. <gdImageWebpCtx> stores the image using a <gdIOCtx> struct.
<gdImageWebpPtrEx> stores the image to RAM. <gdImageWebpPtrEx> stores the image to RAM.
Parameters: Parameters:
im - The image to save. im - The image to save.
outFile - The FILE pointer to write to. outFile - The FILE pointer to write to.
skipping to change at line 348 skipping to change at line 360
} }
/* /*
Function: gdImageWebpPtrEx Function: gdImageWebpPtrEx
See <gdImageWebpEx>. See <gdImageWebpEx>.
*/ */
BGD_DECLARE(void *) gdImageWebpPtrEx (gdImagePtr im, int *size, int quality) BGD_DECLARE(void *) gdImageWebpPtrEx (gdImagePtr im, int *size, int quality)
{ {
void *rv; void *rv;
gdIOCtx *out = gdNewDynamicCtx(2048, NULL); gdIOCtx *out = gdNewDynamicCtx(2048, NULL);
if (out == NULL) { if (out == NULL) {
return NULL; return NULL;
} }
if (_gdImageWebpCtx(im, out, quality)) { if (_gdImageWebpCtx(im, out, quality)) {
rv = NULL; rv = NULL;
} else { } else {
rv = gdDPExtractData(out, size); rv = gdDPExtractData(out, size);
} }
out->gd_free(out); out->gd_free(out);
skipping to change at line 370 skipping to change at line 383
#else /* !HAVE_LIBWEBP */ #else /* !HAVE_LIBWEBP */
static void _noWebpError(void) static void _noWebpError(void)
{ {
gd_error("WEBP image support has been disabled\n"); gd_error("WEBP image support has been disabled\n");
} }
BGD_DECLARE(gdImagePtr) gdImageCreateFromWebp (FILE * inFile) BGD_DECLARE(gdImagePtr) gdImageCreateFromWebp (FILE * inFile)
{ {
ARG_NOT_USED(inFile);
_noWebpError(); _noWebpError();
return NULL; return NULL;
} }
BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpPtr (int size, void *data) BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpPtr (int size, void *data)
{ {
ARG_NOT_USED(size);
ARG_NOT_USED(data);
_noWebpError(); _noWebpError();
return NULL; return NULL;
} }
BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpCtx (gdIOCtx * infile) BGD_DECLARE(gdImagePtr) gdImageCreateFromWebpCtx (gdIOCtx * infile)
{ {
ARG_NOT_USED(infile);
_noWebpError(); _noWebpError();
return NULL; return NULL;
} }
BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality) BGD_DECLARE(void) gdImageWebpCtx (gdImagePtr im, gdIOCtx * outfile, int quality)
{ {
ARG_NOT_USED(im);
ARG_NOT_USED(outfile);
ARG_NOT_USED(quality);
_noWebpError(); _noWebpError();
} }
BGD_DECLARE(void) gdImageWebpEx (gdImagePtr im, FILE * outFile, int quality) BGD_DECLARE(void) gdImageWebpEx (gdImagePtr im, FILE * outFile, int quality)
{ {
ARG_NOT_USED(im);
ARG_NOT_USED(outFile);
ARG_NOT_USED(quality);
_noWebpError(); _noWebpError();
} }
BGD_DECLARE(void) gdImageWebp (gdImagePtr im, FILE * outFile) BGD_DECLARE(void) gdImageWebp (gdImagePtr im, FILE * outFile)
{ {
ARG_NOT_USED(im);
ARG_NOT_USED(outFile);
_noWebpError(); _noWebpError();
} }
BGD_DECLARE(void *) gdImageWebpPtr (gdImagePtr im, int *size) BGD_DECLARE(void *) gdImageWebpPtr (gdImagePtr im, int *size)
{ {
ARG_NOT_USED(im);
ARG_NOT_USED(size);
_noWebpError(); _noWebpError();
return NULL; return NULL;
} }
BGD_DECLARE(void *) gdImageWebpPtrEx (gdImagePtr im, int *size, int quality) BGD_DECLARE(void *) gdImageWebpPtrEx (gdImagePtr im, int *size, int quality)
{ {
ARG_NOT_USED(im);
ARG_NOT_USED(size);
ARG_NOT_USED(quality);
_noWebpError(); _noWebpError();
return NULL; return NULL;
} }
#endif /* HAVE_LIBWEBP */ #endif /* HAVE_LIBWEBP */
 End of changes. 14 change blocks. 
4 lines changed or deleted 35 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)