Preserve original image in wxImageFileProperty

Rescale only the copy of the original image to preserve image quality.
This commit is contained in:
Artur Wieczorek
2022-04-10 13:34:03 +02:00
parent 6c7cf8e6d0
commit 04bad7a720
3 changed files with 10 additions and 6 deletions

View File

@@ -297,7 +297,7 @@ public:
protected:
wxBitmap m_bitmap; // final thumbnail area
wxImage m_image; // intermediate thumbnail area
wxImage m_image; // original thumbnail area
private:
// Initialize m_image using the current file name.

View File

@@ -251,7 +251,7 @@ public:
protected:
wxBitmap m_bitmap; // final thumbnail area
wxImage m_image; // intermediate thumbnail area
wxImage m_image; // original thumbnail area
};

View File

@@ -1876,7 +1876,7 @@ void wxImageFileProperty::OnCustomPaint( wxDC& dc,
const wxRect& rect,
wxPGPaintData& )
{
if ( m_bitmap.IsOk() || m_image.IsOk() )
if ( m_image.IsOk() )
{
// Draw the thumbnail
// Create the bitmap here because required size is not known in OnSetValue().
@@ -1889,11 +1889,15 @@ void wxImageFileProperty::OnCustomPaint( wxDC& dc,
if ( !m_bitmap.IsOk() )
{
m_image.Rescale( rect.width, rect.height );
m_bitmap = wxBitmap(m_image, dc);
wxImage imgScaled = m_image;
imgScaled.Rescale(rect.width, rect.height);
m_bitmap = wxBitmap(imgScaled, dc);
}
}
dc.DrawBitmap( m_bitmap, rect.x, rect.y, false );
if ( m_bitmap.IsOk() )
{
dc.DrawBitmap(m_bitmap, rect.x, rect.y, false);
}
else
{