mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-12 22:14:29 +02:00
introduce a generic WebPPictureHasTransparency() function
VP8-lossy will now avoid writing an ALPH chunk if the alpha values are trivial. + changed DumpPicture() accordingly in cwebp + prevented the -d option to be active with lossless (DumpPicture wouldn't work). Change-Id: I34fdb108a2b6207e93fa6cd00b1d2509a8e1dc4b
This commit is contained in:
@ -650,7 +650,8 @@ static int DumpPicture(const WebPPicture* const picture, const char* PGM_name) {
|
||||
const int uv_width = (picture->width + 1) / 2;
|
||||
const int uv_height = (picture->height + 1) / 2;
|
||||
const int stride = (picture->width + 1) & ~1;
|
||||
const int alpha_height = picture->a ? picture->height : 0;
|
||||
const int alpha_height =
|
||||
WebPPictureHasTransparency(picture) ? picture->height : 0;
|
||||
const int height = picture->height + uv_height + alpha_height;
|
||||
FILE* const f = fopen(PGM_name, "wb");
|
||||
if (f == NULL) return 0;
|
||||
@ -1035,7 +1036,11 @@ int main(int argc, const char *argv[]) {
|
||||
|
||||
// Write info
|
||||
if (dump_file) {
|
||||
DumpPicture(&picture, dump_file);
|
||||
if (picture.use_argb_input) {
|
||||
fprintf(stderr, "Warning: can't dump file (-d option) in lossless mode.");
|
||||
} else if (!DumpPicture(&picture, dump_file)) {
|
||||
fprintf(stderr, "Warning, couldn't dump picture %s\n", dump_file);
|
||||
}
|
||||
}
|
||||
|
||||
if (!quiet) {
|
||||
|
Reference in New Issue
Block a user