[FFmpeg-cvslog] Support transparency in 32bit bmp files.

Carl Eugen Hoyos git at videolan.org
Fri Dec 2 00:27:19 CET 2011


ffmpeg | branch: master | Carl Eugen Hoyos <cehoyos at ag.or.at> | Fri Dec  2 00:21:24 2011 +0100| [8b08f81949bcfa6fec42ff3f1c9bef5be8140300] | committer: Carl Eugen Hoyos

Support transparency in 32bit bmp files.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8b08f81949bcfa6fec42ff3f1c9bef5be8140300
---

 libavcodec/bmp.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c
index 22973aa..3418edc 100644
--- a/libavcodec/bmp.c
+++ b/libavcodec/bmp.c
@@ -154,7 +154,7 @@ static int bmp_decode_frame(AVCodecContext *avctx,
             rgb[2] = 0;
         }
 
-        avctx->pix_fmt = PIX_FMT_BGR24;
+        avctx->pix_fmt = PIX_FMT_BGRA;
         break;
     case 24:
         avctx->pix_fmt = PIX_FMT_BGR24;
@@ -319,7 +319,13 @@ static int bmp_decode_frame(AVCodecContext *avctx,
                     dst[0] = src[rgb[2]];
                     dst[1] = src[rgb[1]];
                     dst[2] = src[rgb[0]];
-                    dst += 3;
+/* The Microsoft documentation states:
+ * "The high byte in each DWORD is not used."
+ * Both GIMP and ImageMagick store the alpha transparency value
+ * in the high byte for 32bit bmp files.
+ */
+                    dst[3] = src[3];
+                    dst += 4;
                     src += 4;
                 }
 



More information about the ffmpeg-cvslog mailing list