Make libimagequant visibility detectable

This commit is contained in:
rr- 2016-05-06 21:05:52 +02:00
parent 0b4a089321
commit 8b7fb44c6b
2 changed files with 11 additions and 18 deletions

View File

@ -1577,6 +1577,7 @@ ImagingQuantize(Imaging im, int colors, int mode, int kmeans)
);
break;
case 3:
#ifdef HAVE_LIBIMAGEQUANT
if (!strcmp(im->mode, "RGBA")) {
withAlpha = 1;
}
@ -1590,6 +1591,9 @@ ImagingQuantize(Imaging im, int colors, int mode, int kmeans)
&newData,
withAlpha
);
#else
result = -1;
#endif
break;
default:
result = 0;
@ -1599,7 +1603,7 @@ ImagingQuantize(Imaging im, int colors, int mode, int kmeans)
free(p);
ImagingSectionLeave(&cookie);
if (result) {
if (result > 0) {
imOut = ImagingNew("P", im->xsize, im->ysize);
ImagingSectionEnter(&cookie);
@ -1639,6 +1643,12 @@ ImagingQuantize(Imaging im, int colors, int mode, int kmeans)
} else {
if (result == -1) {
return (Imaging) ImagingError_ValueError(
"dependency required by this method was not "
"enabled at compile time");
}
return (Imaging) ImagingError_ValueError("quantization error");
}

View File

@ -122,21 +122,4 @@ err:
return result;
}
#else
/* Offer dummy implementation */
int
quantize_pngquant(
Pixel *pixelData,
uint32_t width,
uint32_t height,
uint32_t quantPixels,
Pixel **palette,
uint32_t *paletteLength,
uint32_t **quantizedPixels,
int withAlpha)
{
return 0;
}
#endif