From 568411347bb643c3ba4440ddb44ece6914e432d9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 25 Oct 2021 23:28:05 +0200 Subject: [PATCH] Make wxOSX wxBitmap::CopyFromIcon() work as in the other ports Just use the same object, as wxIcon is the same thing as wxBitmap anyhow, instead of re-creating another wxBitmap which can be subtly different from the original one. Notably, converting an icon with default scale factor of 1 to bitmap when using a high DPI display resulted in a bitmap with the same physical size but scale factor of 2, as wxOSXGetImageScaleFactor() returned 2 in this case, i.e. changed the logical bitmap size. This couldn't be anything other than a bug, so fix this and, at the same time, simplify the code and make it consistent with the other ports. --- src/osx/core/bitmap.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index 2f82e5d9a2..3149731261 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -784,7 +784,8 @@ wxBitmapRefData::~wxBitmapRefData() bool wxBitmap::CopyFromIcon(const wxIcon& icon) { - return Create( icon.OSXGetImage() ); + *this = icon; + return IsOk(); } wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits)