mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-12 22:14:29 +02:00
add a WebPCleanupTransparentArea() method
to 'clean up' the fully-transparent area and make it more compressible new cwebp flags: -alpha_cleanup (off by default, since gain is not 100% guaranteed) Change-Id: I74d77e1915eee146584cd61c9c1132a41db922eb
This commit is contained in:
committed by
James Zern
parent
552c121715
commit
2e3e8b2ef5
@ -206,6 +206,11 @@ static HRESULT ReadPictureWithWIC(const char* filename,
|
||||
if (!ok)
|
||||
hr = E_FAIL;
|
||||
}
|
||||
if (SUCCEEDED(hr)) {
|
||||
if (has_alpha && keep_alpha == 2) {
|
||||
WebPCleanupTransparentArea(pic);
|
||||
}
|
||||
}
|
||||
|
||||
// Cleanup.
|
||||
if (pConverter != NULL) IUnknown_Release(pConverter);
|
||||
@ -416,6 +421,10 @@ static int ReadPNG(FILE* in_file, WebPPicture* const pic, int keep_alpha) {
|
||||
: WebPPictureImportRGB(pic, rgb, stride);
|
||||
free(rgb);
|
||||
|
||||
if (ok && has_alpha && keep_alpha == 2) {
|
||||
WebPCleanupTransparentArea(pic);
|
||||
}
|
||||
|
||||
End:
|
||||
return ok;
|
||||
}
|
||||
@ -702,6 +711,7 @@ static void HelpLong(void) {
|
||||
printf(" -alpha_method <int> .... Transparency-compression method (0..1)\n");
|
||||
printf(" -alpha_filter <string> . predictive filtering for alpha plane.\n");
|
||||
printf(" One of: none, fast (default) or best.\n");
|
||||
printf(" -alpha_cleanup ......... Clean RGB values in transparent area.\n");
|
||||
printf(" -noalpha ............... discard any transparency information.\n");
|
||||
|
||||
printf("\n");
|
||||
@ -795,6 +805,8 @@ int main(int argc, const char *argv[]) {
|
||||
config.alpha_quality = strtol(argv[++c], NULL, 0);
|
||||
} else if (!strcmp(argv[c], "-alpha_method") && c < argc - 1) {
|
||||
config.alpha_compression = strtol(argv[++c], NULL, 0);
|
||||
} else if (!strcmp(argv[c], "-alpha_cleanup")) {
|
||||
keep_alpha = keep_alpha ? 2 : 0;
|
||||
} else if (!strcmp(argv[c], "-alpha_filter") && c < argc - 1) {
|
||||
++c;
|
||||
if (!strcmp(argv[c], "none")) {
|
||||
|
Reference in New Issue
Block a user