mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-21 23:09:40 +00:00
#9130 Text in main work area isn't rendered with high resolution
Add pixel_ratio to graphics params to use it for displays with high resolution. It holds the ratio between physical pixels and device-independent pixels of the graphics.
This commit is contained in:
parent
e7163a0999
commit
82904d4603
@ -191,6 +191,15 @@ public:
|
||||
/// The connection of the signal StatusChanged
|
||||
boost::signals::connection sc_;
|
||||
|
||||
double displayPixelRatio() const
|
||||
{
|
||||
return params_.pixel_ratio;
|
||||
}
|
||||
void setDisplayPixelRatio(double scale)
|
||||
{
|
||||
params_.pixel_ratio = scale;
|
||||
}
|
||||
|
||||
private:
|
||||
///
|
||||
void statusChanged();
|
||||
@ -326,6 +335,18 @@ ImageStatus Loader::status() const
|
||||
}
|
||||
|
||||
|
||||
double Loader::displayPixelRatio() const
|
||||
{
|
||||
return pimpl_->displayPixelRatio();
|
||||
}
|
||||
|
||||
|
||||
void Loader::setDisplayPixelRatio(double scale)
|
||||
{
|
||||
pimpl_->setDisplayPixelRatio(scale);
|
||||
}
|
||||
|
||||
|
||||
boost::signals::connection Loader::connect(slot_type const & slot) const
|
||||
{
|
||||
return pimpl_->signal_.connect(slot);
|
||||
@ -433,6 +454,16 @@ void Loader::Impl::createPixmap()
|
||||
|
||||
image_.reset(cached_item_->image()->clone());
|
||||
|
||||
if (params_.pixel_ratio == 1.0) {
|
||||
string filename = cached_item_->filename().absFileName();
|
||||
size_t idx = filename.find_last_of('.');
|
||||
if (idx != string::npos && idx > 3) {
|
||||
if (filename.substr(idx - 3, 3) == "@2x") {
|
||||
params_.pixel_ratio = 2.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool const success = image_->setPixmap(params_);
|
||||
|
||||
if (success) {
|
||||
|
@ -101,6 +101,9 @@ public:
|
||||
*/
|
||||
Image const * image() const;
|
||||
|
||||
double displayPixelRatio() const;
|
||||
void setDisplayPixelRatio(double scale);
|
||||
|
||||
private:
|
||||
/// Use the Pimpl idiom to hide the internals.
|
||||
class Impl;
|
||||
|
@ -25,6 +25,7 @@ namespace graphics {
|
||||
Params::Params()
|
||||
: display(true),
|
||||
scale(100),
|
||||
pixel_ratio(1.0),
|
||||
angle(0)
|
||||
{}
|
||||
|
||||
@ -35,6 +36,7 @@ bool operator==(Params const & a, Params const & b)
|
||||
a.display == b.display &&
|
||||
a.bb == b.bb &&
|
||||
a.scale == b.scale &&
|
||||
a.pixel_ratio == b.pixel_ratio &&
|
||||
a.angle == b.angle);
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,7 @@ public:
|
||||
|
||||
bool display;
|
||||
unsigned int scale;
|
||||
double pixel_ratio;
|
||||
|
||||
/// The image filename.
|
||||
support::FileName filename;
|
||||
|
Loading…
x
Reference in New Issue
Block a user