From 37f70e5023aff67bf8f63d273b90a3e0bce4c505 Mon Sep 17 00:00:00 2001 From: qPCR4vir Date: Mon, 27 May 2024 01:18:06 +0200 Subject: [PATCH] use def api::screen_dpi() instead of 96 & avoid copy old graphics?? --- include/nana/paint/graphics.hpp | 2 +- source/paint/graphics.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/nana/paint/graphics.hpp b/include/nana/paint/graphics.hpp index a3f2a44f..1240a3f0 100644 --- a/include/nana/paint/graphics.hpp +++ b/include/nana/paint/graphics.hpp @@ -108,7 +108,7 @@ namespace nana class graphics { public: - explicit graphics(int dpi = 96); + explicit graphics(int dpi = 0); graphics(const ::nana::size& sz, int dpi );//= 96 ///< size in pixel graphics(const graphics&); ///< the resource is not copyed, the two graphics objects refer to the *SAME* resource graphics& operator=(const graphics&); diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index 2388721d..866e6d88 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include "../detail/platform_abstraction.hpp" @@ -281,17 +282,18 @@ namespace paint nana::paint::font ft{ info.value(), dpi }; typeface(ft); make(sz); // this will scale the size to the dpi - bitblt(0, 0, duplicate); + //bitblt(0, 0, duplicate); } int graphics::get_dpi() const { return impl_->dpi; } graphics::graphics(int dpi) - : impl_(new implementation{.dpi{dpi}, .scale{dpi/96.0f}}) + : impl_(new implementation{.dpi {dpi?dpi: api::screen_dpi()}, + .scale{(dpi?dpi: api::screen_dpi())/96.0f}}) { auto info = typeface().info(); - nana::paint::font ft{ info.value(), dpi }; + nana::paint::font ft{ info.value(), impl_->dpi }; typeface(ft); }