diff --git a/extras/extras.c b/extras/extras.c index dcb30395..2feb595c 100644 --- a/extras/extras.c +++ b/extras/extras.c @@ -48,13 +48,14 @@ int WebPImportGray(const uint8_t* gray_data, WebPPicture* pic) { int WebPImportRGB565(const uint8_t* rgb565, WebPPicture* pic) { int x, y; + uint32_t* dst; if (pic == NULL || rgb565 == NULL) return 0; pic->colorspace = WEBP_YUV420; pic->use_argb = 1; if (!WebPPictureAlloc(pic)) return 0; + dst = pic->argb; for (y = 0; y < pic->height; ++y) { const int width = pic->width; - uint32_t* dst = pic->argb + y * pic->argb_stride; for (x = 0; x < width; ++x) { #ifdef WEBP_SWAP_16BIT_CSP const uint32_t rg = rgb565[2 * x + 1]; @@ -70,22 +71,24 @@ int WebPImportRGB565(const uint8_t* rgb565, WebPPicture* pic) { r = r | (r >> 5); g = g | (g >> 6); b = b | (b >> 5); - dst[x] = (r << 16) | (g << 8) | b; + dst[x] = (0xffu << 24) | (r << 16) | (g << 8) | b; } rgb565 += 2 * width; + dst += pic->argb_stride; } return 1; } int WebPImportRGB4444(const uint8_t* rgb4444, WebPPicture* pic) { int x, y; + uint32_t* dst; if (pic == NULL || rgb4444 == NULL) return 0; pic->colorspace = WEBP_YUV420; pic->use_argb = 1; if (!WebPPictureAlloc(pic)) return 0; + dst = pic->argb; for (y = 0; y < pic->height; ++y) { const int width = pic->width; - uint32_t* dst = pic->argb + y * pic->argb_stride; for (x = 0; x < width; ++x) { #ifdef WEBP_SWAP_16BIT_CSP const uint32_t rg = rgb4444[2 * x + 1]; @@ -106,6 +109,7 @@ int WebPImportRGB4444(const uint8_t* rgb4444, WebPPicture* pic) { dst[x] = (a << 24) | (r << 16) | (g << 8) | b; } rgb4444 += 2 * width; + dst += pic->argb_stride; } return 1; }