From 8e20a9cfb1b049db8316e754392d1cfc483f94e4 Mon Sep 17 00:00:00 2001 From: Cyril Deguet Date: Sun, 6 Nov 2005 17:05:50 +0000 Subject: [PATCH] * winamp2.xml: hack to support nums_ex.bmp and numbers.bmp * theme_loader.cpp: correct handling of subdirectories in winamp skins --- modules/gui/skins2/parser/builder.cpp | 13 +++++++++++++ modules/gui/skins2/src/file_bitmap.cpp | 2 +- modules/gui/skins2/src/generic_bitmap.cpp | 5 +++++ modules/gui/skins2/src/theme_loader.cpp | 23 ++++++++++++++--------- share/skins2/winamp2.xml | 1 + 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/modules/gui/skins2/parser/builder.cpp b/modules/gui/skins2/parser/builder.cpp index 5099e8a640..22ef1deb13 100644 --- a/modules/gui/skins2/parser/builder.cpp +++ b/modules/gui/skins2/parser/builder.cpp @@ -146,6 +146,12 @@ void Builder::addBitmap( const BuilderData::Bitmap &rData ) GenericBitmap *pBmp = new FileBitmap( getIntf(), m_pImageHandler, rData.m_fileName, rData.m_alphaColor ); + if( !pBmp->getData() ) + { + // Invalid bitmap + delete pBmp; + return; + } m_pTheme->m_bitmaps[rData.m_id] = GenericBitmapPtr( pBmp ); } @@ -175,6 +181,13 @@ void Builder::addBitmapFont( const BuilderData::BitmapFont &rData ) { GenericBitmap *pBmp = new FileBitmap( getIntf(), m_pImageHandler, rData.m_file, 0 ); + if( !pBmp->getData() ) + { + // invalid bitmap + delete pBmp; + return; + } + m_pTheme->m_bitmaps[rData.m_id] = GenericBitmapPtr( pBmp ); GenericFont *pFont = new BitmapFont( getIntf(), *pBmp, rData.m_type ); diff --git a/modules/gui/skins2/src/file_bitmap.cpp b/modules/gui/skins2/src/file_bitmap.cpp index b831b4c51e..99fcc5d862 100644 --- a/modules/gui/skins2/src/file_bitmap.cpp +++ b/modules/gui/skins2/src/file_bitmap.cpp @@ -28,7 +28,7 @@ FileBitmap::FileBitmap( intf_thread_t *pIntf, image_handler_t *pImageHandler, string fileName, uint32_t aColor ): - GenericBitmap( pIntf ), m_width( 0 ), m_height( 0 ) + GenericBitmap( pIntf ), m_width( 0 ), m_height( 0 ), m_pData( NULL ) { video_format_t fmt_in = {0}, fmt_out = {0}; picture_t *pPic; diff --git a/modules/gui/skins2/src/generic_bitmap.cpp b/modules/gui/skins2/src/generic_bitmap.cpp index e839d64f2e..c3d69922eb 100644 --- a/modules/gui/skins2/src/generic_bitmap.cpp +++ b/modules/gui/skins2/src/generic_bitmap.cpp @@ -44,6 +44,11 @@ void BitmapImpl::drawBitmap( const GenericBitmap &rSource, int xSrc, int ySrc, { int srcWidth = rSource.getWidth(); uint32_t *pSrc = (uint32_t*)rSource.getData() + ySrc * srcWidth + xSrc; + if( !pSrc ) + { + return; + } + uint32_t *pDest = (uint32_t*)m_pData + yDest * m_width + xDest ; for( int y = 0; y < height; y++ ) { diff --git a/modules/gui/skins2/src/theme_loader.cpp b/modules/gui/skins2/src/theme_loader.cpp index cd760a22d1..b48a45338e 100644 --- a/modules/gui/skins2/src/theme_loader.cpp +++ b/modules/gui/skins2/src/theme_loader.cpp @@ -283,16 +283,21 @@ bool ThemeLoader::extract( const string &fileName ) } else { - // No XML file, assume it is a winamp2 skin - path = tempPath; - - // Look for winamp2.xml in the resource path - list resPath = pOsFactory->getResourcePath(); - list::const_iterator it; - for( it = resPath.begin(); it != resPath.end(); it++ ) + // No XML file, check if it is a winamp2 skin + string mainBmp; + if( findFile( tempPath, "main.bmp", mainBmp ) ) { - if( findFile( *it, WINAMP2_XML_FILE, xmlFile ) ) - break; + msg_Dbg( getIntf(), "Try to load a winamp2 skin" ); + path = getFilePath( mainBmp ); + + // Look for winamp2.xml in the resource path + list resPath = pOsFactory->getResourcePath(); + list::const_iterator it; + for( it = resPath.begin(); it != resPath.end(); it++ ) + { + if( findFile( *it, WINAMP2_XML_FILE, xmlFile ) ) + break; + } } } diff --git a/share/skins2/winamp2.xml b/share/skins2/winamp2.xml index 7e924e0ad4..cb709c7551 100644 --- a/share/skins2/winamp2.xml +++ b/share/skins2/winamp2.xml @@ -22,6 +22,7 @@ + -- 2.39.2