[MPlayer-cvslog] r33622 - in trunk/gui: mplayer/gui_common.c mplayer/menu.c util/bitmap.c util/bitmap.h win32/widgetrender.c
ib
subversion at mplayerhq.hu
Thu Jun 16 13:19:16 CEST 2011
Author: ib
Date: Thu Jun 16 13:19:15 2011
New Revision: 33622
Log:
Remove function Normalize().
This function changed ARGB data as if it had been RGB24 data (not quite
correctly) converted to ARGB with all colors transparent.
Instead now, set the alpha channel for RGB24 data and leave ARGB data
untouched.
For X11, the alpha channel is disregarded, so both approaches are equal,
but the new one is more intelligible as we get correct ARGB PNG data.
For legacy reasons, all kind of fuchsia/magenta must be treated as
transparent, because some skins are using at least both full opaque and
full transparent fuchsia/magenta for transparency.
Modified:
trunk/gui/mplayer/gui_common.c
trunk/gui/mplayer/menu.c
trunk/gui/util/bitmap.c
trunk/gui/util/bitmap.h
trunk/gui/win32/widgetrender.c
Modified: trunk/gui/mplayer/gui_common.c
==============================================================================
--- trunk/gui/mplayer/gui_common.c Thu Jun 16 11:27:31 2011 (r33621)
+++ trunk/gui/mplayer/gui_common.c Thu Jun 16 13:19:15 2011 (r33622)
@@ -333,7 +333,7 @@ static void PutImage(txSample *bf, int x
for (ix = x; ix < (int)(x + bf->Width); ix++) {
tmp = drw[i++];
- if (tmp != TRANSPARENT)
+ if (!IS_TRANSPARENT(tmp))
buf[iy * image_width + ix] = tmp;
}
#else
@@ -343,7 +343,7 @@ static void PutImage(txSample *bf, int x
for (ix = x; ix < (int)(x + bf->Width); ix++) {
tmp = drw[i++];
- if (tmp != TRANSPARENT)
+ if (!IS_TRANSPARENT(tmp))
buf[yc + ix] = tmp;
}
@@ -371,7 +371,7 @@ static void SimplePotmeterPutImage(txSam
for (ix = x; ix < (int)(x + w); ix++) {
tmp = drw[i++];
- if (tmp != TRANSPARENT)
+ if (!IS_TRANSPARENT(tmp))
buf[iy * image_width + ix] = tmp;
}
Modified: trunk/gui/mplayer/menu.c
==============================================================================
--- trunk/gui/mplayer/menu.c Thu Jun 16 11:27:31 2011 (r33621)
+++ trunk/gui/mplayer/menu.c Thu Jun 16 13:19:15 2011 (r33622)
@@ -56,7 +56,7 @@ static void mplMenuDraw( void )
for ( x=appMPlayer.menuItems[ mplMenuItem ].x; x < appMPlayer.menuItems[ mplMenuItem ].x + appMPlayer.menuItems[ mplMenuItem ].width; x++ )
{
tmp=drw[ y * appMPlayer.menuSelected.width + x ];
- if ( tmp != TRANSPARENT ) buf[ y * appMPlayer.menu.width + x ]=tmp;
+ if ( !IS_TRANSPARENT ( tmp ) ) buf[ y * appMPlayer.menu.width + x ]=tmp;
}
}
mplOldMenuItem=mplMenuItem;
Modified: trunk/gui/util/bitmap.c
==============================================================================
--- trunk/gui/util/bitmap.c Thu Jun 16 11:27:31 2011 (r33621)
+++ trunk/gui/util/bitmap.c Thu Jun 16 13:19:15 2011 (r33622)
@@ -156,7 +156,7 @@ static int Convert24to32(txSample *bf)
mp_dbg(MSGT_GPLAYER, MSGL_DBG2, "[bitmap] 32 bpp conversion size: %lu\n", bf->ImageSize);
for (c = 0, i = 0; c < bf->ImageSize; c += 4, i += 3)
- *(uint32_t *)&bf->Image[c] = AV_RB24(&orgImage[i]);
+ *(uint32_t *)&bf->Image[c] = ALPHA_OPAQUE | AV_RB24(&orgImage[i]);
free(orgImage);
}
@@ -164,18 +164,6 @@ static int Convert24to32(txSample *bf)
return 1;
}
-static void Normalize(txSample *bf)
-{
- unsigned long i;
-
- for (i = 0; i < bf->ImageSize; i += 4)
-#if HAVE_BIGENDIAN
- bf->Image[i] = 0;
-#else
- bf->Image[i + 3] = 0;
-#endif
-}
-
static unsigned char *fExist(unsigned char *fname)
{
static const char ext[][4] = { "png", "PNG" };
@@ -219,8 +207,6 @@ int bpRead(char *fname, txSample *bf)
if (!Convert24to32(bf))
return -8;
- Normalize(bf);
-
return 0;
}
@@ -254,7 +240,7 @@ int Convert32to1(txSample *in, txSample
for (i = 0; i < out->Width * out->Height; i++) {
tmp >>= 1;
- if (buf[i] != TRANSPARENT)
+ if (!IS_TRANSPARENT(buf[i]))
tmp |= 0x80;
else {
buf[i] = 0;
Modified: trunk/gui/util/bitmap.h
==============================================================================
--- trunk/gui/util/bitmap.h Thu Jun 16 11:27:31 2011 (r33621)
+++ trunk/gui/util/bitmap.h Thu Jun 16 13:19:15 2011 (r33622)
@@ -19,7 +19,11 @@
#ifndef MPLAYER_GUI_BITMAP_H
#define MPLAYER_GUI_BITMAP_H
-#define TRANSPARENT 0x00ff00ff // transparent color (fuchsia/magenta)
+#define TRANSPARENT 0xffff00ff // transparent color (opaque fuchsia/magenta)
+#define ALPHA_OPAQUE 0xff000000
+
+// for legacy reasons, we must treat all kind of fuchsia/magenta as transparent
+#define IS_TRANSPARENT(c) ((ALPHA_OPAQUE | (c)) == TRANSPARENT)
typedef struct {
unsigned long Width;
Modified: trunk/gui/win32/widgetrender.c
==============================================================================
--- trunk/gui/win32/widgetrender.c Thu Jun 16 11:27:31 2011 (r33621)
+++ trunk/gui/win32/widgetrender.c Thu Jun 16 13:19:15 2011 (r33622)
@@ -50,7 +50,7 @@ static void render(int bitsperpixel, ima
}
else if(bpp > 2)
{
- if(!transparent || *((unsigned int *) (src->data + soffset + (i * src->width * bpp) + c)) != 0x00ff00ff)
+ if(!transparent || !IS_TRANSPARENT(*((unsigned int *) (src->data + soffset + (i * src->width * bpp) + c))))
memcpy(dst->data + offset + c, src->data + soffset + (i * src->width * bpp) + c, bpp);
}
}
More information about the MPlayer-cvslog
mailing list