From cd25766b79d5a4bc71da6af3fa6a66fa7c56446c Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Mon, 19 Aug 2019 22:42:36 +0200 Subject: [PATCH 1/3] Try to get image-scaling working correctly --- openlp/core/display/html/display.js | 3 ++- openlp/core/widgets/views.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/openlp/core/display/html/display.js b/openlp/core/display/html/display.js index 56e3c0a48..203709e00 100644 --- a/openlp/core/display/html/display.js +++ b/openlp/core/display/html/display.js @@ -428,7 +428,8 @@ var Display = { section.setAttribute("data-background", "#000"); var img = document.createElement('img'); img.src = slide["path"]; - img.setAttribute("style", "height: 100%; width: 100%;"); + //img.setAttribute("style", "height: 100%; width: 100%;"); + img.setAttribute("style", "max-width: 100%; height: auto; vertical-align: middle"); section.appendChild(img); slidesDiv.appendChild(section); Display._slides[index.toString()] = index; diff --git a/openlp/core/widgets/views.py b/openlp/core/widgets/views.py index c3f4be0ca..e80e46cf4 100644 --- a/openlp/core/widgets/views.py +++ b/openlp/core/widgets/views.py @@ -210,9 +210,10 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties): pixmap = QtGui.QPixmap(str(slide['image'])) else: pixmap = QtGui.QPixmap(str(slide['path'])) + pixmap_ratio = pixmap.width() / pixmap.height() label.setPixmap(pixmap) container = QtWidgets.QWidget() - layout = AspectRatioLayout(container, self.screen_ratio) + layout = AspectRatioLayout(container, pixmap_ratio) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(label) container.setLayout(layout) From 62ca28cf094453dde3f426fb813485ca63799ea2 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Wed, 21 Aug 2019 21:13:27 +0200 Subject: [PATCH 2/3] Improve image scaling on display --- openlp/core/display/html/display.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/core/display/html/display.js b/openlp/core/display/html/display.js index 203709e00..76937ea4f 100644 --- a/openlp/core/display/html/display.js +++ b/openlp/core/display/html/display.js @@ -426,10 +426,10 @@ var Display = { var section = document.createElement("section"); section.setAttribute("id", index); section.setAttribute("data-background", "#000"); + section.setAttribute("style", "height: 100%; width: 100%;"); var img = document.createElement('img'); img.src = slide["path"]; - //img.setAttribute("style", "height: 100%; width: 100%;"); - img.setAttribute("style", "max-width: 100%; height: auto; vertical-align: middle"); + img.setAttribute("style", "max-width: 100%; height: auto; margin: 0; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);"); section.appendChild(img); slidesDiv.appendChild(section); Display._slides[index.toString()] = index; From aae8b5b81132c4b0f894501c7273d8f7c3c9e357 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Wed, 21 Aug 2019 21:45:05 +0200 Subject: [PATCH 3/3] Fix test --- openlp/core/widgets/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openlp/core/widgets/views.py b/openlp/core/widgets/views.py index e80e46cf4..a1d065307 100644 --- a/openlp/core/widgets/views.py +++ b/openlp/core/widgets/views.py @@ -210,7 +210,10 @@ class ListPreviewWidget(QtWidgets.QTableWidget, RegistryProperties): pixmap = QtGui.QPixmap(str(slide['image'])) else: pixmap = QtGui.QPixmap(str(slide['path'])) - pixmap_ratio = pixmap.width() / pixmap.height() + if pixmap.height() > 0: + pixmap_ratio = pixmap.width() / pixmap.height() + else: + pixmap_ratio = 1 label.setPixmap(pixmap) container = QtWidgets.QWidget() layout = AspectRatioLayout(container, pixmap_ratio)