mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
pixconv: add PIXEL_FORMAT__YA_NONPREMUL support
Binary size, before: 115152 gen/lib/c/clang-dynamic/wuffs-base-pixconv.lo 115152 gen/lib/c/clang-static/wuffs-base-pixconv.o 162280 gen/lib/c/gcc-dynamic/wuffs-base-pixconv.lo 165352 gen/lib/c/gcc-static/wuffs-base-pixconv.o After: 123464 gen/lib/c/clang-dynamic/wuffs-base-pixconv.lo 123464 gen/lib/c/clang-static/wuffs-base-pixconv.o 180768 gen/lib/c/gcc-dynamic/wuffs-base-pixconv.lo 180880 gen/lib/c/gcc-static/wuffs-base-pixconv.o Updates #143
This commit is contained in:
1 parent
0c9b700df0
commit
bdfbdf407e
6 files changed
+943
No files matched your search
@@ -69,6 +69,26 @@ wuffs_base__color_u32_argb_premul__as__color_u8_gray(
|
||||
return (uint8_t)(weighted_average >> 24);
|
||||
}
|
||||
|
||||
static inline uint16_t //
|
||||
wuffs_base__color_u32_argb_premul__as__color_u16_alpha_gray_nonpremul(
|
||||
wuffs_base__color_u32_argb_premul c) {
|
||||
uint32_t a = 0xFF & (c >> 24);
|
||||
if (a == 0) {
|
||||
return 0;
|
||||
}
|
||||
uint32_t a16 = a * 0x101;
|
||||
|
||||
uint32_t cr = 0xFF & (c >> 16);
|
||||
cr = (cr * (0x101 * 0xFFFF)) / a16;
|
||||
uint32_t cg = 0xFF & (c >> 8);
|
||||
cg = (cg * (0x101 * 0xFFFF)) / a16;
|
||||
uint32_t cb = 0xFF & (c >> 0);
|
||||
cb = (cb * (0x101 * 0xFFFF)) / a16;
|
||||
|
||||
uint32_t weighted_average = (19595 * cr) + (38470 * cg) + (7471 * cb) + 32768;
|
||||
return (uint16_t)((a16 & 0xFF00) | (weighted_average >> 24));
|
||||
}
|
||||
|
||||
static inline uint16_t //
|
||||
wuffs_base__color_u32_argb_premul__as__color_u16_gray(
|
||||
wuffs_base__color_u32_argb_premul c) {
|
||||
|
||||
Reference in new issue
Block a user