extras: add WebPUnmultiplyARGB() convenience function

This is useful for converting associated to unassociated.

Change-Id: I0e6d16ec63cb5514a0f945c14a54e0d01e1fab0a
This commit is contained in:
Skal
2019-10-24 21:20:03 +02:00
committed by James Zern
parent 22cbae33e5
commit 47178dbd45
3 changed files with 27 additions and 2 deletions

View File

@ -12,6 +12,7 @@
#include "extras/extras.h"
#include "webp/format_constants.h"
#include "src/dsp/dsp.h"
#include <assert.h>
#include <string.h>
@ -144,3 +145,18 @@ int WebPImportColorMappedARGB(const uint8_t* indexed, int indexed_stride,
}
//------------------------------------------------------------------------------
int WebPUnmultiplyARGB(WebPPicture* pic) {
int y;
uint32_t* dst;
if (pic == NULL || pic->use_argb != 1 || pic->argb == NULL) return 0;
WebPInitAlphaProcessing();
dst = pic->argb;
for (y = 0; y < pic->height; ++y) {
WebPMultARGBRow(dst, pic->width, /*inverse=*/1);
dst += pic->argb_stride;
}
return 1;
}
//------------------------------------------------------------------------------