Skip to content

Commit

Permalink
use def api::screen_dpi() instead of 96 & avoid copy old graphics??
Browse files Browse the repository at this point in the history
  • Loading branch information
qPCR4vir committed May 26, 2024
1 parent a4f55ae commit 37f70e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/nana/paint/graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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&);
Expand Down
8 changes: 5 additions & 3 deletions source/paint/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <nana/paint/pixel_buffer.hpp>
#include <nana/gui/layout_utility.hpp>
#include <nana/unicode_bidi.hpp>
#include <nana/gui/programming_interface.hpp>

#include "../detail/platform_abstraction.hpp"

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 37f70e5

Please sign in to comment.