mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-20 04:18:26 +01:00
extras: add WebPUnmultiplyARGB() convenience function
This is useful for converting associated to unassociated. Change-Id: I0e6d16ec63cb5514a0f945c14a54e0d01e1fab0a
This commit is contained in:
parent
22cbae33e5
commit
47178dbd45
@ -525,7 +525,9 @@ if(WEBP_BUILD_EXTRAS)
|
|||||||
# webp_quality
|
# webp_quality
|
||||||
add_executable(webp_quality ${WEBP_QUALITY_SRCS} ${WEBP_EXTRAS_SRCS})
|
add_executable(webp_quality ${WEBP_QUALITY_SRCS} ${WEBP_EXTRAS_SRCS})
|
||||||
target_link_libraries(webp_quality exampleutil imagedec)
|
target_link_libraries(webp_quality exampleutil imagedec)
|
||||||
target_include_directories(webp_quality PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
target_include_directories(webp_quality
|
||||||
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR})
|
||||||
install(TARGETS webp_quality RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
install(TARGETS webp_quality RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
|
||||||
# vwebp_sdl
|
# vwebp_sdl
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "extras/extras.h"
|
#include "extras/extras.h"
|
||||||
#include "webp/format_constants.h"
|
#include "webp/format_constants.h"
|
||||||
|
#include "src/dsp/dsp.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.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;
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
@ -19,7 +19,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include "webp/encode.h"
|
#include "webp/encode.h"
|
||||||
|
|
||||||
#define WEBP_EXTRAS_ABI_VERSION 0x0001 // MAJOR(8b) + MINOR(8b)
|
#define WEBP_EXTRAS_ABI_VERSION 0x0002 // MAJOR(8b) + MINOR(8b)
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -51,6 +51,13 @@ WebPImportColorMappedARGB(const uint8_t* indexed, int indexed_stride,
|
|||||||
const uint32_t palette[], int palette_size,
|
const uint32_t palette[], int palette_size,
|
||||||
WebPPicture* pic);
|
WebPPicture* pic);
|
||||||
|
|
||||||
|
// Convert the ARGB content of 'pic' from associated to unassociated.
|
||||||
|
// 'pic' can be for instance the result of calling of some WebPPictureImportXXX
|
||||||
|
// functions, with pic->use_argb set to 'true'. It is assumed (and not checked)
|
||||||
|
// that the pre-multiplied r/g/b values as less or equal than the alpha value.
|
||||||
|
// Return false in case of error (invalid parameter, ...).
|
||||||
|
WEBP_EXTERN int WebPUnmultiplyARGB(WebPPicture* pic);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Parse a bitstream, search for VP8 (lossy) header and report a
|
// Parse a bitstream, search for VP8 (lossy) header and report a
|
||||||
|
Loading…
Reference in New Issue
Block a user