mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-16 13:59:51 +02:00
Provide option to swap bytes for 16 bit colormodes
Color modes: RGB_565 & RGBA_4444 Change-Id: I571b6832b9848e5c4109272978f68623ca373383
This commit is contained in:
@ -1033,8 +1033,15 @@ static void ConvertBGRAToRGBA4444(const uint32_t* src,
|
||||
const uint32_t* const src_end = src + num_pixels;
|
||||
while (src < src_end) {
|
||||
const uint32_t argb = *src++;
|
||||
*dst++ = ((argb >> 16) & 0xf0) | ((argb >> 12) & 0xf);
|
||||
*dst++ = ((argb >> 0) & 0xf0) | ((argb >> 28) & 0xf);
|
||||
const uint8_t rg = ((argb >> 16) & 0xf0) | ((argb >> 12) & 0xf);
|
||||
const uint8_t ba = ((argb >> 0) & 0xf0) | ((argb >> 28) & 0xf);
|
||||
#ifdef WEBP_SWAP_16BIT_CSP
|
||||
*dst++ = ba;
|
||||
*dst++ = rg;
|
||||
#else
|
||||
*dst++ = rg;
|
||||
*dst++ = ba;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -1043,8 +1050,15 @@ static void ConvertBGRAToRGB565(const uint32_t* src,
|
||||
const uint32_t* const src_end = src + num_pixels;
|
||||
while (src < src_end) {
|
||||
const uint32_t argb = *src++;
|
||||
*dst++ = ((argb >> 16) & 0xf8) | ((argb >> 13) & 0x7);
|
||||
*dst++ = ((argb >> 5) & 0xe0) | ((argb >> 3) & 0x1f);
|
||||
const uint8_t rg = ((argb >> 16) & 0xf8) | ((argb >> 13) & 0x7);
|
||||
const uint8_t gb = ((argb >> 5) & 0xe0) | ((argb >> 3) & 0x1f);
|
||||
#ifdef WEBP_SWAP_16BIT_CSP
|
||||
*dst++ = gb;
|
||||
*dst++ = rg;
|
||||
#else
|
||||
*dst++ = rg;
|
||||
*dst++ = gb;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user