mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-06 14:29:54 +08:00
scale in-place image preview according to scale factor
This commit is contained in:
parent
dba154b2c3
commit
966d9fb7d7
@ -284,16 +284,22 @@ QString VPreviewManager::imageResourceName(const ImageLinkInfo &p_link)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resize the image.
|
// Resize the image.
|
||||||
|
qreal sf = VUtils::calculateScaleFactor();
|
||||||
if (p_link.m_width > 0) {
|
if (p_link.m_width > 0) {
|
||||||
if (p_link.m_height > 0) {
|
if (p_link.m_height > 0) {
|
||||||
m_editor->addImage(name, image.scaled(p_link.m_width, p_link.m_height));
|
m_editor->addImage(name, image.scaled(p_link.m_width * sf,
|
||||||
|
p_link.m_height * sf));
|
||||||
} else {
|
} else {
|
||||||
m_editor->addImage(name, image.scaledToWidth(p_link.m_width));
|
m_editor->addImage(name, image.scaledToWidth(p_link.m_width * sf));
|
||||||
}
|
}
|
||||||
} else if (p_link.m_height > 0) {
|
} else if (p_link.m_height > 0) {
|
||||||
m_editor->addImage(name, image.scaledToHeight(p_link.m_height));
|
m_editor->addImage(name, image.scaledToHeight(p_link.m_height * sf));
|
||||||
} else {
|
} else {
|
||||||
|
if (sf < 1.1) {
|
||||||
m_editor->addImage(name, image);
|
m_editor->addImage(name, image);
|
||||||
|
} else {
|
||||||
|
m_editor->addImage(name, image.scaledToWidth(image.width() * sf));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user