diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2019-04-12 11:11:13 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2019-04-12 13:56:53 +0200 |
commit | 812f0a83d223cddf00b121db40ca7ff91c22ccfa (patch) | |
tree | 8137fdfbac1f3c50bcd5b55ef66cd036aef0e455 /framework/source | |
parent | ed437865a0db175e45ff421d50f429dff421d0cf (diff) |
internally resize image instead of scaling bitmaps outside
When we want a different size Image, we can now set that as a
parameter at construction of the Image. Previously we needed to
create an Image, forcefully take the bitmap out, resize the bitmap
and create a new Image out of that.
Doing it internally gives us the benefit to have a more control
over the scaling process, especially when dealing with HiDPI
images.
Change-Id: I104118f4d863d519cc7aad1a17ca0289c01ed9ff
Reviewed-on: https://gerrit.libreoffice.org/70617
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'framework/source')
-rw-r--r-- | framework/source/uielement/popuptoolbarcontroller.cxx | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/framework/source/uielement/popuptoolbarcontroller.cxx b/framework/source/uielement/popuptoolbarcontroller.cxx index 94d056daf60d..6d325ff4f452 100644 --- a/framework/source/uielement/popuptoolbarcontroller.cxx +++ b/framework/source/uielement/popuptoolbarcontroller.cxx @@ -785,25 +785,17 @@ void NewToolbarController::setItemImage( const OUString &rCommand ) bool bBig = SvtMiscOptions().AreCurrentSymbolsLarge(); INetURLObject aURLObj( aURL ); - Image aImage = SvFileInformationManager::GetImageNoDefault( aURLObj, bBig ); - if ( !aImage ) - aImage = !!aMenuImage ? - aMenuImage : - SvFileInformationManager::GetImage( aURLObj, bBig ); - + Size aPreferredSize(bBig ? pToolBox->GetDefaultImageSize() : Size()); + Image aImage = SvFileInformationManager::GetImageNoDefault(aURLObj, bBig, aPreferredSize); + if (!aImage) + { + aImage = !!aMenuImage ? aMenuImage : SvFileInformationManager::GetImage(aURLObj, bBig, aPreferredSize); + } // if everything failed, just use the image associated with the toolbar item command if ( !aImage ) return; - Size aBigSize( pToolBox->GetDefaultImageSize() ); - if ( bBig && aImage.GetSizePixel() != aBigSize ) - { - BitmapEx aScaleBmpEx( aImage.GetBitmapEx() ); - aScaleBmpEx.Scale( aBigSize, BmpScaleFlag::Interpolate ); - pToolBox->SetItemImage( m_nToolBoxId, Image( aScaleBmpEx ) ); - } - else - pToolBox->SetItemImage( m_nToolBoxId, aImage ); + pToolBox->SetItemImage( m_nToolBoxId, aImage ); m_aLastURL = aURL; } |