Work around poor image scaling on WIN32, especially on HiDPI displays where all images without size specification will be scaled
This commit is contained in:
parent
c3ae2fc54a
commit
f8bc9abfc4
@ -465,17 +465,7 @@ void wxHtmlImageCell::SetImage(const wxImage& img)
|
|||||||
if ( m_bmpH == wxDefaultCoord)
|
if ( m_bmpH == wxDefaultCoord)
|
||||||
m_bmpH = hh;
|
m_bmpH = hh;
|
||||||
|
|
||||||
// Only scale the bitmap at the rendering stage,
|
m_bitmap = new wxBitmap(img);
|
||||||
// so we don't lose quality twice
|
|
||||||
/*
|
|
||||||
if ((m_bmpW != ww) || (m_bmpH != hh))
|
|
||||||
{
|
|
||||||
wxImage img2 = img.Scale(m_bmpW, m_bmpH);
|
|
||||||
m_bitmap = new wxBitmap(img2);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
*/
|
|
||||||
m_bitmap = new wxBitmap(img);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -605,6 +595,24 @@ void wxHtmlImageCell::Draw(wxDC& dc, int x, int y,
|
|||||||
// and height, so we only do the scaling once.
|
// and height, so we only do the scaling once.
|
||||||
double imageScaleX = 1.0;
|
double imageScaleX = 1.0;
|
||||||
double imageScaleY = 1.0;
|
double imageScaleY = 1.0;
|
||||||
|
|
||||||
|
// Optimisation for Windows: WIN32 scaling for window DCs is very poor,
|
||||||
|
// so unless we're using a printer DC, do the scaling ourselves.
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
if (m_Width >= 0 && m_Width != m_bitmap->GetWidth() && !dc.IsKindOf(CLASSINFO(wxPrinterDC)))
|
||||||
|
{
|
||||||
|
wxImage image(m_bitmap->ConvertToImage());
|
||||||
|
if (image.HasMask())
|
||||||
|
{
|
||||||
|
// Convert the mask to an alpha channel or scaling won't work correctly
|
||||||
|
image.InitAlpha();
|
||||||
|
}
|
||||||
|
image.Rescale(m_Width, m_Height, wxIMAGE_QUALITY_HIGH);
|
||||||
|
delete m_bitmap;
|
||||||
|
m_bitmap = new wxBitmap(image);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (m_Width != m_bitmap->GetWidth())
|
if (m_Width != m_bitmap->GetWidth())
|
||||||
imageScaleX = (double) m_Width / (double) m_bitmap->GetWidth();
|
imageScaleX = (double) m_Width / (double) m_bitmap->GetWidth();
|
||||||
if (m_Height != m_bitmap->GetHeight())
|
if (m_Height != m_bitmap->GetHeight())
|
||||||
|
Loading…
Reference in New Issue
Block a user