Mercurial > mplayer.hg
changeset 21895:5d9486bbc156
Implement gif transparency
author | reimar |
---|---|
date | Sat, 13 Jan 2007 12:56:02 +0000 |
parents | 449b9fb6f67b |
children | b2640a639ac7 |
files | libmpdemux/demux_gif.c |
diffstat | 1 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/demux_gif.c Sat Jan 13 12:46:27 2007 +0000 +++ b/libmpdemux/demux_gif.c Sat Jan 13 12:56:02 2007 +0000 @@ -53,6 +53,8 @@ ColorMapObject *effective_map = NULL; char *buf = NULL; int refmode = 0; + int transparency = 0; + uint8_t transparent_col; while (type != IMAGE_DESC_RECORD_TYPE) { if (DGifGetRecordType(gif, &type) == GIF_ERROR) { @@ -78,8 +80,10 @@ int frametime = 0; if (p[0] == 4) // is the length correct? { + transparency = p[1] & 1; frametime = (p[3] << 8) | p[2]; // set the time, centiseconds refmode = (p[1] >> 2) & 3; + transparent_col = p[4]; } priv->current_pts += frametime; } else if ((code == 0xFE) && (verbose)) { // comment extension @@ -144,6 +148,20 @@ priv->palette[(y * 4) + 3] = 0; } + if (transparency) { + uint8_t *dpos = dest, *spos = buf; + int hleft = h; + while (hleft-- > 0) { + int wleft = w; + while (wleft-- > 0) { + if (*spos != transparent_col) + *dpos = *spos; + dpos++; spos++; + } + dpos += priv->w - w; + spos += gif->Image.Width - w; + } + } else memcpy_pic(dest, buf, w, h, priv->w, gif->Image.Width); if (refmode == 1) memcpy(priv->refimg, dp->buffer, priv->w * priv->h);