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

@@ -1134,7 +1134,7 @@ bool wxBitmap::Create(const void* data, wxBitmapType type, int width, int height
#if wxUSE_IMAGE
wxBitmap::wxBitmap(const wxImage& image, int depth, double scale)
void wxBitmap::InitFromImage(const wxImage& image, int depth, double scale)
{
wxCHECK_RET( image.IsOk(), wxT("invalid image") );
@@ -1235,6 +1235,16 @@ wxBitmap::wxBitmap(const wxImage& image, int depth, double scale)
}
}
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());
}
wxImage wxBitmap::ConvertToImage() const
{
wxImage image;