Commit 386742db authored by Olivier Teulière's avatar Olivier Teulière

* skins2/controls/ctrl_image.cpp: Avoid a crash when resizing a Image control

   to a very small size, in scaling mode
parent e0a50df3
...@@ -100,17 +100,20 @@ void CtrlImage::draw( OSGraphics &rImage, int xDest, int yDest ) ...@@ -100,17 +100,20 @@ void CtrlImage::draw( OSGraphics &rImage, int xDest, int yDest )
if( m_resizeMethod == kScale ) if( m_resizeMethod == kScale )
{ {
// Use scaling method // Use scaling method
if( width != m_pImage->getWidth() || if( width > 1 && height > 1 )
height != m_pImage->getHeight() )
{ {
OSFactory *pOsFactory = OSFactory::instance( getIntf() ); if( width != m_pImage->getWidth() ||
// Rescale the image with the actual size of the control height != m_pImage->getHeight() )
ScaledBitmap bmp( getIntf(), m_rBitmap, width, height ); {
SKINS_DELETE( m_pImage ); OSFactory *pOsFactory = OSFactory::instance( getIntf() );
m_pImage = pOsFactory->createOSGraphics( width, height ); // Rescale the image with the actual size of the control
m_pImage->drawBitmap( bmp, 0, 0 ); ScaledBitmap bmp( getIntf(), m_rBitmap, width, height );
SKINS_DELETE( m_pImage );
m_pImage = pOsFactory->createOSGraphics( width, height );
m_pImage->drawBitmap( bmp, 0, 0 );
}
rImage.drawGraphics( *m_pImage, 0, 0, xDest, yDest );
} }
rImage.drawGraphics( *m_pImage, 0, 0, xDest, yDest );
} }
else else
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment