diff --git a/src/common/bmpbndl.cpp b/src/common/bmpbndl.cpp index becd229c9c..f89c3490f4 100644 --- a/src/common/bmpbndl.cpp +++ b/src/common/bmpbndl.cpp @@ -384,7 +384,16 @@ wxBitmap wxBitmapBundle::GetBitmap(const wxSize& size) const if ( !m_impl ) return wxBitmap(); - return m_impl->GetBitmap(size == wxDefaultSize ? GetDefaultSize() : size); + const wxSize sizeDef = GetDefaultSize(); + + wxBitmap bmp = m_impl->GetBitmap(size == wxDefaultSize ? sizeDef : size); + + // Ensure that the returned bitmap uses the scale factor such that it takes + // the same space, in logical pixels, as the bitmap in the default size. + if ( size != wxDefaultSize ) + bmp.SetScaleFactor(static_cast(size.y)/sizeDef.y); + + return bmp; } // ============================================================================ diff --git a/src/gtk/image_gtk.cpp b/src/gtk/image_gtk.cpp index 98ef9a8589..518b313f99 100644 --- a/src/gtk/image_gtk.cpp +++ b/src/gtk/image_gtk.cpp @@ -155,24 +155,13 @@ static gboolean wxGtkImageDraw(GtkWidget* widget, GdkEventExpose* event) #endif } - const double scaleFactor = image->m_provider->GetScale(); - GtkAllocation alloc; gtk_widget_get_allocation(widget, &alloc); - int x = (alloc.width - int(bitmap.GetWidth() /scaleFactor)) / 2; - int y = (alloc.height - int(bitmap.GetHeight()/scaleFactor)) / 2; + int x = (alloc.width - int(bitmap.GetScaledWidth() )) / 2; + int y = (alloc.height - int(bitmap.GetScaledHeight())) / 2; #ifdef __WXGTK3__ gtk_render_background(gtk_widget_get_style_context(widget), cr, 0, 0, alloc.width, alloc.height); - - if (!wxIsSameDouble(scaleFactor, 1)) - { - cairo_translate(cr, x, y); - const double scale = 1 / scaleFactor; - cairo_scale(cr, scale, scale); - x = 0; - y = 0; - } bitmap.Draw(cr, x, y); #else x += alloc.x;