Using Screen.devicePixelRatio as image depth.

Fixes bluriness of images on HDPI screens and disabling it on those who don't need it.
This commit is contained in:
Adsooi 2022-10-22 14:16:15 +02:00
parent d969661b33
commit fb1c4c0de7
Signed by: Ad5001
GPG key ID: 7251B1AF90B960F9
4 changed files with 10 additions and 6 deletions

View file

@ -18,6 +18,7 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQml 2.12 import QtQml 2.12
import QtQuick.Window 2.12
import "../js/objects.js" as Objects import "../js/objects.js" as Objects
import "../js/historylib.js" as HistoryLib import "../js/historylib.js" as HistoryLib
import "../js/history/common.js" as HistoryCommon import "../js/history/common.js" as HistoryCommon
@ -215,5 +216,6 @@ Item {
Component.onCompleted: { Component.onCompleted: {
HistoryLib.history = historyObj HistoryLib.history = historyObj
HistoryCommon.themeTextColor = sysPalette.windowText HistoryCommon.themeTextColor = sysPalette.windowText
HistoryCommon.imageDepth = Screen.devicePixelRatio
} }
} }

View file

@ -19,6 +19,7 @@
import QtQuick 2.12 import QtQuick 2.12
import QtQuick.Dialogs 1.3 as D import QtQuick.Dialogs 1.3 as D
import QtQuick.Controls 2.12 import QtQuick.Controls 2.12
import QtQuick.Window 2.12
import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting import eu.ad5001.LogarithmPlotter.Setting 1.0 as Setting
import "../js/objects.js" as Objects import "../js/objects.js" as Objects
import "../js/historylib.js" as HistoryLib import "../js/historylib.js" as HistoryLib
@ -100,8 +101,8 @@ Item {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left anchors.left: parent.left
visible: LatexJS.enabled visible: LatexJS.enabled
property double depth: 2 property double depth: Screen.devicePixelRatio
property var ltxInfo: visible ? Latex.render(obj.getLatexString(), depth*parent.font.pixelSize+4, parent.color).split(",") : ["","0","0"] property var ltxInfo: visible ? Latex.render(obj.getLatexString(), depth*(parent.font.pixelSize+2), parent.color).split(",") : ["","0","0"]
source: visible ? ltxInfo[0] : "" source: visible ? ltxInfo[0] : ""
width: parseInt(ltxInfo[1])/depth width: parseInt(ltxInfo[1])/depth
height: parseInt(ltxInfo[2])/depth height: parseInt(ltxInfo[2])/depth

View file

@ -15,7 +15,8 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import QtQuick 2.7 import QtQuick 2.12
import QtQuick.Window 2.12
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
/*! /*!
@ -48,8 +49,8 @@ Item {
width: parent.width width: parent.width
//smooth: true //smooth: true
visible: false visible: false
sourceSize.width: width*2 sourceSize.width: width*Screen.devicePixelRatio
sourceSize.height: width*2 sourceSize.height: width*Screen.devicePixelRatio
} }
ColorOverlay { ColorOverlay {
anchors.fill: img anchors.fill: img

View file

@ -98,7 +98,7 @@ class Action {
renderLatexAsHtml(latexString) { renderLatexAsHtml(latexString) {
if(!Latex.enabled) if(!Latex.enabled)
throw new Error("Cannot render an item as LaTeX when LaTeX is disabled.") throw new Error("Cannot render an item as LaTeX when LaTeX is disabled.")
let latexInfo = Latex.Renderer.render(latexString, imageDepth*fontSize+4, themeTextColor).split(",") let latexInfo = Latex.Renderer.render(latexString, imageDepth*(fontSize+2), themeTextColor).split(",")
return `<img src="${latexInfo[0]}" width="${parseInt(latexInfo[1])/imageDepth}" height="${parseInt(latexInfo[2])/imageDepth}" style="vertical-align: middle"></img>` return `<img src="${latexInfo[0]}" width="${parseInt(latexInfo[1])/imageDepth}" height="${parseInt(latexInfo[2])/imageDepth}" style="vertical-align: middle"></img>`
} }