1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teulière <ipkiss@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
29 #include <vlc_common.h>
30 #include <vlc_image.h>
32 #include "file_bitmap.hpp"
34 FileBitmap::FileBitmap( intf_thread_t
*pIntf
, image_handler_t
*pImageHandler
,
35 string fileName
, uint32_t aColor
, int nbFrames
,
36 int fps
, int nbLoops
):
37 GenericBitmap( pIntf
, nbFrames
, fps
, nbLoops
), m_width( 0 ), m_height( 0 ),
40 video_format_t fmt_in
= {0}, fmt_out
= {0};
43 fmt_out
.i_chroma
= VLC_CODEC_RGBA
;
45 char* psz_uri
= make_URI( fileName
.c_str(), NULL
);
46 pPic
= image_ReadUrl( pImageHandler
, psz_uri
, &fmt_in
, &fmt_out
);
52 m_width
= fmt_out
.i_width
;
53 m_height
= fmt_out
.i_height
;
55 m_pData
= new uint8_t[m_height
* m_width
* 4];
57 // Compute the alpha layer
58 uint8_t *pData
= m_pData
, *pSrc
= pPic
->p
->p_pixels
;
59 for( int y
= 0; y
< m_height
; y
++ )
61 for( int x
= 0; x
< m_width
; x
++ )
68 *(pData
++) = b
* a
/ 255;
69 *(pData
++) = g
* a
/ 255;
70 *(pData
++) = r
* a
/ 255;
72 // Transparent pixel ?
73 if( aColor
== (r
<<16 | g
<<8 | b
) )
83 pSrc
+= pPic
->p
->i_pitch
- m_width
* 4;
86 picture_Release( pPic
);
91 FileBitmap::~FileBitmap()
97 uint8_t *FileBitmap::getData() const
101 msg_Warn( getIntf(), "FileBitmap::getData() returns NULL" );