diff --git a/include/wx/bitmap.h b/include/wx/bitmap.h index 68e49a03ea..6b31c71c37 100644 --- a/include/wx/bitmap.h +++ b/include/wx/bitmap.h @@ -177,8 +177,7 @@ public: virtual bool Create(int width, int height, int depth = wxBITMAP_SCREEN_DEPTH) = 0; virtual bool Create(const wxSize& sz, int depth = wxBITMAP_SCREEN_DEPTH) = 0; - virtual bool CreateScaled(int w, int h, int d, double logicalScale) - { return Create(wxRound(w*logicalScale), wxRound(h*logicalScale), d); } + virtual bool CreateScaled(int w, int h, int d, double logicalScale); virtual int GetHeight() const = 0; virtual int GetWidth() const = 0; @@ -188,12 +187,11 @@ public: { return wxSize(GetWidth(), GetHeight()); } // support for scaled bitmaps - virtual void SetScaleFactor(double WXUNUSED(scale)) { } - virtual double GetScaleFactor() const { return 1.0; } - virtual double GetScaledWidth() const { return GetWidth() / GetScaleFactor(); } - virtual double GetScaledHeight() const { return GetHeight() / GetScaleFactor(); } - virtual wxSize GetScaledSize() const - { return wxSize(wxRound(GetScaledWidth()), wxRound(GetScaledHeight())); } + virtual void SetScaleFactor(double scale); + virtual double GetScaleFactor() const; + virtual double GetScaledWidth() const; + virtual double GetScaledHeight() const; + virtual wxSize GetScaledSize() const; #if wxUSE_IMAGE virtual wxImage ConvertToImage() const = 0; diff --git a/include/wx/msw/bitmap.h b/include/wx/msw/bitmap.h index 9672fc437d..21ebdec47f 100644 --- a/include/wx/msw/bitmap.h +++ b/include/wx/msw/bitmap.h @@ -158,8 +158,7 @@ public: virtual bool Create(int width, int height, const wxDC& dc); virtual bool Create(const void* data, wxBitmapType type, int width, int height, int depth = 1); - virtual bool CreateScaled(int w, int h, int d, double logicalScale) - { return Create(wxRound(w*logicalScale), wxRound(h*logicalScale), d); } + virtual bool CreateScaled(int w, int h, int d, double logicalScale); virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_DEFAULT_TYPE); virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const; @@ -185,12 +184,12 @@ public: void UseAlpha(bool use = true); void ResetAlpha() { UseAlpha(false); } - // support for scaled bitmaps - virtual void SetScaleFactor(double WXUNUSED(scale)) { } - virtual double GetScaleFactor() const { return 1.0; } - virtual double GetScaledWidth() const { return GetWidth(); } - virtual double GetScaledHeight() const { return GetHeight(); } - virtual wxSize GetScaledSize() const { return GetSize(); } + // provide stabs of scaled bitmaps functions, they are trivial here + virtual void SetScaleFactor(double scale); + virtual double GetScaleFactor() const; + virtual double GetScaledWidth() const; + virtual double GetScaledHeight() const; + virtual wxSize GetScaledSize() const; // implementation only from now on // ------------------------------- diff --git a/src/common/bmpbase.cpp b/src/common/bmpbase.cpp index 7634981844..1136d1f1d2 100644 --- a/src/common/bmpbase.cpp +++ b/src/common/bmpbase.cpp @@ -196,6 +196,39 @@ public: wxIMPLEMENT_DYNAMIC_CLASS(wxBitmapBaseModule, wxModule); +// ---------------------------------------------------------------------------- +// Trivial implementations of scale-factor related functions +// ---------------------------------------------------------------------------- + +bool wxBitmapBase::CreateScaled(int w, int h, int d, double logicalScale) +{ + return Create(wxRound(w*logicalScale), wxRound(h*logicalScale), d); +} + +void wxBitmapBase::SetScaleFactor(double WXUNUSED(scale)) +{ +} + +double wxBitmapBase::GetScaleFactor() const +{ + return 1.0; +} + +double wxBitmapBase::GetScaledWidth() const +{ + return GetWidth() / GetScaleFactor(); +} + +double wxBitmapBase::GetScaledHeight() const +{ + return GetHeight() / GetScaleFactor(); +} + +wxSize wxBitmapBase::GetScaledSize() const +{ + return wxSize(wxRound(GetScaledWidth()), wxRound(GetScaledHeight())); +} + #endif // wxUSE_BITMAP_BASE // ---------------------------------------------------------------------------- diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index 30b2d439a6..c63dd61089 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -745,6 +745,11 @@ bool wxBitmap::Create(int width, int height, const wxDC& dc) return false; } +bool wxBitmap::CreateScaled(int w, int h, int d, double logicalScale) +{ + return Create(wxRound(w*logicalScale), wxRound(h*logicalScale), d); +} + bool wxBitmap::DoCreate(int w, int h, int d, WXHDC hdc) { UnRef(); @@ -1357,6 +1362,39 @@ bool wxBitmap::InitFromHBITMAP(WXHBITMAP bmp, int width, int height, int depth) return IsOk(); } +// ---------------------------------------------------------------------------- +// scale factor-related functions +// ---------------------------------------------------------------------------- + +// Note: currently we don't use scale factor at all and don't even store it +// because this seems useless, but we define these functions out of line here +// and not inline in the header to make it possible to change this later +// without breaking ABI if necessary. + +void wxBitmap::SetScaleFactor(double WXUNUSED(scale)) +{ +} + +double wxBitmap::GetScaleFactor() const +{ + return 1.0; +} + +double wxBitmap::GetScaledWidth() const +{ + return GetWidth(); +} + +double wxBitmap::GetScaledHeight() const +{ + return GetHeight(); +} + +wxSize wxBitmap::GetScaledSize() const +{ + return GetSize(); +} + // ---------------------------------------------------------------------------- // raw bitmap access support // ----------------------------------------------------------------------------