Add wxBitmap(wxImage, wxDC) ctor to all ports

This ctor was previously present only in wxMSW, make it available in all
ports to allow the same code to compile everywhere.

In most of them wxDC argument is simply ignored, but in wxGTK and wxOSX
it is used to assign the appropriate scale factor for the new bitmap.

Enable previously wxMSW-only unit test checking for this.
This commit is contained in:
Vadim Zeitlin
2022-04-12 17:44:59 +01:00
parent b185186ebf
commit 24970061fa
12 changed files with 74 additions and 17 deletions

View File

@@ -14,6 +14,7 @@
#include <QtWidgets/QLabel>
#ifndef WX_PRECOMP
#include "wx/dc.h"
#include "wx/icon.h"
#include "wx/image.h"
#endif // WX_PRECOMP
@@ -209,7 +210,7 @@ wxBitmap::wxBitmap(const wxString &filename, wxBitmapType type )
LoadFile(filename, type);
}
wxBitmap::wxBitmap(const wxImage& image, int depth, double WXUNUSED(scale) )
void wxBitmap::InitFromImage(const wxImage& image, int depth, double WXUNUSED(scale) )
{
Qt::ImageConversionFlags flags = 0;
if (depth == 1)
@@ -217,6 +218,16 @@ wxBitmap::wxBitmap(const wxImage& image, int depth, double WXUNUSED(scale) )
m_refData = new wxBitmapRefData(QPixmap::fromImage(ConvertImage(image), flags));
}
wxBitmap::wxBitmap(const wxImage& image, int depth, double scale)
{
InitFromImage(image, depth, scale);
}
wxBitmap::wxBitmap(const wxImage& image, const wxDC& dc)
{
InitFromImage(image, -1, dc.GetContentScaleFactor());
}
wxBitmap::wxBitmap(const wxCursor& cursor)
{
// note that pixmap could be invalid if is not a pixmap cursor