# HG changeset patch # User ib # Date 1327622865 0 # Node ID a9d2dcb0f4356b231208d19622ea03b9ba9abb08 # Parent e421fb9bb0b9e95f32876b441d4c4228b5e7051f Fix skin PNG read errors. FFmpeg's PNG decoder no longer does transcoding, but returns 32 bpp images in RGBA format. Extend (and rename) the existing 24 bpp to 32 bpp conversion function to do 32 bpp ARGB conversion as well. diff -r e421fb9bb0b9 -r a9d2dcb0f435 gui/util/bitmap.c --- a/gui/util/bitmap.c Thu Jan 26 23:16:43 2012 +0000 +++ b/gui/util/bitmap.c Fri Jan 27 00:07:45 2012 +0000 @@ -114,8 +114,7 @@ img->Bpp = 24; break; - case PIX_FMT_BGRA: - case PIX_FMT_ARGB: + case PIX_FMT_RGBA: img->Bpp = 32; break; @@ -151,15 +150,16 @@ } /** - * @brief Convert a 24-bit color depth image into an 32-bit one. + * @brief Convert a 24-bit RGB or 32-bit RGBA image into a 32-bit ARGB image. * * @param img image to be converted * * @return 1 (ok) or 0 (error) * - * @note This is an in-place conversion, new memory will be allocated for @a img. + * @note This is an in-place conversion, + * new memory will be allocated for @a img if necessary. */ -static int Convert24to32(guiImage *img) +static int convert_ARGB(guiImage *img) { char *orgImage; unsigned long i, c; @@ -183,7 +183,13 @@ *(uint32_t *)&img->Image[c] = ALPHA_OPAQUE | AV_RB24(&orgImage[i]); free(orgImage); - } + } else if (img->Bpp == 32) { + mp_msg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] 32 bpp ARGB conversion\n"); + + for (i = 0; i < img->ImageSize; i += 4) + *(uint32_t *)&img->Image[i] = (img->Image[i + 3] << 24) | AV_RB24(&img->Image[i]); + } else + return 0; return 1; } @@ -221,7 +227,7 @@ * @param img pointer suitable to store the image data * * @return 0 (ok), -1 (color depth too low), -2 (not accessible), - * -5 (#pngRead() error) or -8 (#Convert24to32() error) + * -5 (#pngRead() error) or -8 (#convert_ARGB() error) */ int bpRead(const char *fname, guiImage *img) { @@ -244,7 +250,7 @@ return -1; } - if (!Convert24to32(img)) + if (!convert_ARGB(img)) return -8; return 0;