Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
fb482724
Commit
fb482724
authored
Dec 16, 2004
by
Gildas Bazin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* modules/gui/skins2/*: use image handler to load graphic files.
parent
c21b2610
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
100 deletions
+43
-100
modules/gui/skins2/parser/builder.cpp
modules/gui/skins2/parser/builder.cpp
+13
-4
modules/gui/skins2/parser/builder.hpp
modules/gui/skins2/parser/builder.hpp
+4
-1
modules/gui/skins2/src/png_bitmap.cpp
modules/gui/skins2/src/png_bitmap.cpp
+24
-93
modules/gui/skins2/src/png_bitmap.hpp
modules/gui/skins2/src/png_bitmap.hpp
+2
-2
No files found.
modules/gui/skins2/parser/builder.cpp
View file @
fb482724
...
...
@@ -48,12 +48,19 @@
#include "../utils/var_bool.hpp"
#include "../utils/var_text.hpp"
#include "vlc_image.h"
Builder
::
Builder
(
intf_thread_t
*
pIntf
,
const
BuilderData
&
rData
)
:
Builder
::
Builder
(
intf_thread_t
*
pIntf
,
const
BuilderData
&
rData
)
:
SkinObject
(
pIntf
),
m_rData
(
rData
),
m_pTheme
(
NULL
)
{
m_pImageHandler
=
image_HandlerCreate
(
pIntf
);
}
Builder
::~
Builder
()
{
if
(
m_pImageHandler
)
image_HandlerDelete
(
m_pImageHandler
);
}
CmdGeneric
*
Builder
::
parseAction
(
const
string
&
rAction
)
{
...
...
@@ -133,15 +140,17 @@ void Builder::addTheme( const BuilderData::Theme &rData )
void
Builder
::
addBitmap
(
const
BuilderData
::
Bitmap
&
rData
)
{
GenericBitmap
*
pBmp
=
new
PngBitmap
(
getIntf
(),
rData
.
m_fileName
,
rData
.
m_alphaColor
);
GenericBitmap
*
pBmp
=
new
PngBitmap
(
getIntf
(),
m_pImageHandler
,
rData
.
m_fileName
,
rData
.
m_alphaColor
);
m_pTheme
->
m_bitmaps
[
rData
.
m_id
]
=
GenericBitmapPtr
(
pBmp
);
}
void
Builder
::
addBitmapFont
(
const
BuilderData
::
BitmapFont
&
rData
)
{
GenericBitmap
*
pBmp
=
new
PngBitmap
(
getIntf
(),
rData
.
m_file
,
0
);
GenericBitmap
*
pBmp
=
new
PngBitmap
(
getIntf
(),
m_pImageHandler
,
rData
.
m_file
,
0
);
m_pTheme
->
m_bitmaps
[
rData
.
m_id
]
=
GenericBitmapPtr
(
pBmp
);
GenericFont
*
pFont
=
new
BitmapFont
(
getIntf
(),
*
pBmp
,
rData
.
m_type
);
...
...
modules/gui/skins2/parser/builder.hpp
View file @
fb482724
...
...
@@ -47,7 +47,7 @@ class Builder: public SkinObject
{
public:
Builder
(
intf_thread_t
*
pIntf
,
const
BuilderData
&
rData
);
virtual
~
Builder
()
{}
virtual
~
Builder
()
;
/// Create a Theme object, ready to use.
/// Return NULL in case of problem
...
...
@@ -90,6 +90,9 @@ class Builder: public SkinObject
/// Function to parse "points" tags
Bezier
*
getPoints
(
const
char
*
pTag
)
const
;
/// Image handler (used to load image files)
image_handler_t
*
m_pImageHandler
;
};
#endif
...
...
modules/gui/skins2/src/png_bitmap.cpp
View file @
fb482724
...
...
@@ -22,122 +22,53 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include <png.h>
#include <vlc/vlc.h>
#include "vlc_image.h"
#include "png_bitmap.hpp"
PngBitmap
::
PngBitmap
(
intf_thread_t
*
pIntf
,
string
fileName
,
uint32_t
aColor
)
:
GenericBitmap
(
pIntf
),
m_width
(
0
),
m_height
(
0
),
m_pData
(
NULL
)
PngBitmap
::
PngBitmap
(
intf_thread_t
*
pIntf
,
image_handler_t
*
pImageHandler
,
string
fileName
,
uint32_t
aColor
)
:
GenericBitmap
(
pIntf
),
m_width
(
0
),
m_height
(
0
)
{
// Open the PNG file
FILE
*
pFile
=
fopen
(
fileName
.
c_str
(),
"rb"
);
if
(
pFile
==
NULL
)
{
msg_Err
(
getIntf
(),
"Cannot open bitmap %s"
,
fileName
.
c_str
()
);
return
;
}
video_format_t
fmt_in
=
{
0
},
fmt_out
=
{
0
};
picture_t
*
pPic
;
// Create the PNG structures
png_structp
pReadStruct
=
png_create_read_struct
(
PNG_LIBPNG_VER_STRING
,
NULL
,
NULL
,
NULL
);
if
(
pReadStruct
==
NULL
)
{
msg_Err
(
getIntf
(),
"Failed to create PNG read struct"
);
return
;
}
png_infop
pInfo
=
png_create_info_struct
(
pReadStruct
);
if
(
pInfo
==
NULL
)
{
png_destroy_read_struct
(
&
pReadStruct
,
NULL
,
NULL
);
msg_Err
(
getIntf
(),
"Failed to create PNG info struct"
);
return
;
}
png_infop
pEndInfo
=
png_create_info_struct
(
pReadStruct
);
if
(
pEndInfo
==
NULL
)
{
png_destroy_read_struct
(
&
pReadStruct
,
NULL
,
NULL
);
msg_Err
(
getIntf
(),
"Failed to create PNG end info struct"
);
return
;
}
fmt_out
.
i_chroma
=
VLC_FOURCC
(
'R'
,
'V'
,
'3'
,
'2'
);
// Initialize the PNG reader
png_init_io
(
pReadStruct
,
pFile
)
;
pPic
=
image_ReadUrl
(
pImageHandler
,
fileName
.
c_str
(),
&
fmt_in
,
&
fmt_out
);
if
(
!
pPic
)
return
;
// Read the image header
png_read_info
(
pReadStruct
,
pInfo
);
m_width
=
png_get_image_width
(
pReadStruct
,
pInfo
);
m_height
=
png_get_image_height
(
pReadStruct
,
pInfo
);
int
depth
=
png_get_bit_depth
(
pReadStruct
,
pInfo
);
int
colorType
=
png_get_color_type
(
pReadStruct
,
pInfo
);
m_width
=
fmt_out
.
i_width
;
m_height
=
fmt_out
.
i_height
;
// Convert paletted images to RGB
if
(
colorType
==
PNG_COLOR_TYPE_PALETTE
)
{
png_set_palette_to_rgb
(
pReadStruct
);
}
// Strip to 8 bits per channel
if
(
depth
==
16
)
{
png_set_strip_16
(
pReadStruct
);
}
// 4 bytes per pixel
if
(
!
(
colorType
&
PNG_COLOR_MASK_ALPHA
)
)
{
png_set_filler
(
pReadStruct
,
0xff
,
PNG_FILLER_AFTER
);
}
// Invert colors
if
(
colorType
&
PNG_COLOR_MASK_COLOR
)
{
png_set_bgr
(
pReadStruct
);
}
png_read_update_info
(
pReadStruct
,
pInfo
);
// Allocate memory for the buffers
m_pData
=
new
uint8_t
[
m_height
*
m_width
*
4
];
uint8_t
**
pRows
=
new
uint8_t
*
[
m_height
];
for
(
int
i
=
0
;
i
<
m_height
;
i
++
)
{
pRows
[
i
]
=
m_pData
+
(
i
*
m_width
*
4
);
}
// Read the image
png_read_image
(
pReadStruct
,
pRows
);
png_read_end
(
pReadStruct
,
pEndInfo
);
// Compute the alpha layer
uint8_t
*
pData
=
m_pData
;
uint8_t
*
pData
=
m_pData
,
*
pSrc
=
pPic
->
p
->
p_pixels
;
for
(
int
y
=
0
;
y
<
m_height
;
y
++
)
{
for
(
int
x
=
0
;
x
<
m_width
;
x
++
)
{
uint32_t
b
=
(
uint32_t
)
*
(
pData
++
);
uint32_t
g
=
(
uint32_t
)
*
(
pData
++
);
uint32_t
r
=
(
uint32_t
)
*
(
pData
++
);
uint32_t
b
=
(
uint32_t
)
*
(
pData
++
)
=
(
uint32_t
)
*
(
pSrc
++
);
uint32_t
g
=
(
uint32_t
)
*
(
pData
++
)
=
(
uint32_t
)
*
(
pSrc
++
);
uint32_t
r
=
(
uint32_t
)
*
(
pData
++
)
=
(
uint32_t
)
*
(
pSrc
++
);
(
uint32_t
)
*
pData
=
(
uint32_t
)
*
pSrc
;
// Transparent pixel ?
if
(
aColor
==
(
r
<<
16
|
g
<<
8
|
b
)
)
{
*
pData
=
0
;
}
pData
++
;
if
(
aColor
==
(
r
<<
16
|
g
<<
8
|
b
)
)
*
pData
=
0
;
pData
++
;
pSrc
++
;
}
pSrc
+=
pPic
->
p
->
i_pitch
-
m_width
*
4
;
}
// Free the structures
png_destroy_read_struct
(
&
pReadStruct
,
&
pInfo
,
&
pEndInfo
);
delete
[]
pRows
;
// Close the file
fclose
(
pFile
);
pPic
->
pf_release
(
pPic
);
return
;
}
PngBitmap
::~
PngBitmap
()
{
if
(
m_pData
)
{
delete
[]
m_pData
;
}
if
(
m_pData
)
delete
[]
m_pData
;
}
...
...
modules/gui/skins2/src/png_bitmap.hpp
View file @
fb482724
...
...
@@ -35,8 +35,8 @@ class PngBitmap: public GenericBitmap
public:
/// Load a PNG bitmap from a file. aColor is the transparency
/// color, in the format 0xRRGGBB
PngBitmap
(
intf_thread_t
*
pIntf
,
string
fileName
,
uint32_t
aColor
);
PngBitmap
(
intf_thread_t
*
pIntf
,
image_handler_t
*
pImageHandler
,
string
fileName
,
uint32_t
aColor
);
virtual
~
PngBitmap
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment