commit:     68d2bc286976cef43b53bf84573e6d15a75404e0
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Sun May  5 21:01:17 2019 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Wed May  8 17:03:34 2019 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=68d2bc28

media-gfx/kxstitch: Fix for importing images for V6 of ImageMagick

See also: https://mail.kde.org/pipermail/kxstitch/2018-October/000006.html

Reported-by: Dave Armstrong
Package-Manager: Portage-2.3.66, Repoman-2.3.12
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 .../files/kxstitch-2.1.1-imagemagick-fix.patch     | 99 ++++++++++++++++++++++
 media-gfx/kxstitch/kxstitch-2.1.1-r2.ebuild        | 46 ++++++++++
 2 files changed, 145 insertions(+)

diff --git a/media-gfx/kxstitch/files/kxstitch-2.1.1-imagemagick-fix.patch 
b/media-gfx/kxstitch/files/kxstitch-2.1.1-imagemagick-fix.patch
new file mode 100644
index 00000000000..bf8c5e14096
--- /dev/null
+++ b/media-gfx/kxstitch/files/kxstitch-2.1.1-imagemagick-fix.patch
@@ -0,0 +1,99 @@
+From 75a129d3c2f21914a47b970df822e485aca625ac Mon Sep 17 00:00:00 2001
+From: Steve Allewell <[email protected]>
+Date: Sun, 11 Nov 2018 15:48:50 +0000
+Subject: Fix for importing images for V6 of ImageMagick
+
+The getPixelColor in V6 of ImageMagick does not appear to return the
+same information as in V7, consequently importing images has resulted in
+a black image when using V6 of ImageMagick.  This fix reverts the change
+made in commit 295773f44bfda1227d85edf065a8de14dc889159 when using V6.
+
+Big thanks to Sean Enck for reporting and helping diagnose the problem.
+---
+ src/ImportImageDlg.cpp | 16 ++++++++++++++++
+ src/MainWindow.cpp     | 17 +++++++++++++++++
+ 2 files changed, 33 insertions(+)
+
+diff --git a/src/ImportImageDlg.cpp b/src/ImportImageDlg.cpp
+index e6396c6..340ff1d 100644
+--- a/src/ImportImageDlg.cpp
++++ b/src/ImportImageDlg.cpp
+@@ -391,9 +391,21 @@ void ImportImageDlg::renderPixmap()
+     QProgressDialog progress(i18n("Rendering preview"), i18n("Cancel"), 0, 
pixelCount, this);
+     progress.setWindowModality(Qt::WindowModal);
+ 
++/*
++ * ImageMagick prior to V7 used matte (opacity) to determine if an image has 
transparency.
++ * 0.0 for transparent to 1.0 for opaque
++ * 
++ * ImageMagick V7 now uses alpha (transparency).
++ * 1.0 for transparent to 0.0 for opaque
++ * 
++ * Access to pixels has changed too, V7 can use pixelColor to access the 
color of a particular
++ * pixel, but although this was available in V6, it doesn't appear to produce 
the same result
++ * and has resulted in black images when importing.
++ */
+ #if MagickLibVersion < 0x700
+     bool hasTransparency = m_convertedImage.matte();
+     double transparent = 1.0;
++    const Magick::PixelPacket *pixels = m_convertedImage.getConstPixels(0, 0, 
width, height);
+ #else
+     bool hasTransparency = m_convertedImage.alpha();
+     double transparent = 0.0;
+@@ -408,7 +420,11 @@ void ImportImageDlg::renderPixmap()
+         }
+ 
+         for (int dx = 0 ; dx < width ; dx++) {
++#if MagickLibVersion < 0x700
++            Magick::ColorRGB rgb = Magick::Color(*pixels++);
++#else
+             Magick::ColorRGB rgb = m_convertedImage.pixelColor(dx, dy);
++#endif
+ 
+             if (hasTransparency && (rgb.alpha() == transparent)) {
+                 //ignore this pixel as it is transparent
+diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
+index 1f12f5b..ecf552a 100644
+--- a/src/MainWindow.cpp
++++ b/src/MainWindow.cpp
+@@ -541,13 +541,26 @@ void MainWindow::convertImage(const QString &source)
+ 
+         bool useFractionals = importImageDlg->useFractionals();
+ 
++/*
++ * ImageMagick prior to V7 used matte (opacity) to determine if an image has 
transparency.
++ * 0.0 for transparent to 1.0 for opaque
++ * 
++ * ImageMagick V7 now uses alpha (transparency).
++ * 1.0 for transparent to 0.0 for opaque
++ * 
++ * Access to pixels has changed too, V7 can use pixelColor to access the 
color of a particular
++ * pixel, but although this was available in V6, it doesn't appear to produce 
the same result
++ * and has resulted in black images when importing.
++ */
+ #if MagickLibVersion < 0x700
+         bool hasTransparency = convertedImage.matte();
+         double transparent = 1.0;
++        const Magick::PixelPacket *pixels = convertedImage.getConstPixels(0, 
0, imageWidth, imageHeight);
+ #else
+         bool hasTransparency = convertedImage.alpha();
+         double transparent = 0.0;
+ #endif
++        
+         bool ignoreColor = importImageDlg->ignoreColor();
+         Magick::Color ignoreColorValue = importImageDlg->ignoreColorValue();
+ 
+@@ -579,7 +592,11 @@ void MainWindow::convertImage(const QString &source)
+             }
+ 
+             for (int dx = 0 ; dx < imageWidth ; dx++) {
++#if MagickLibVersion < 0x700
++                Magick::ColorRGB rgb = Magick::Color(*pixels++); // is this a 
memory leak
++#else
+                 Magick::ColorRGB rgb = convertedImage.pixelColor(dx, dy);
++#endif
+                 
+                 if (hasTransparency && (rgb.alpha() == transparent)) {
+                     // ignore this pixel as it is transparent
+-- 
+cgit v1.1

diff --git a/media-gfx/kxstitch/kxstitch-2.1.1-r2.ebuild 
b/media-gfx/kxstitch/kxstitch-2.1.1-r2.ebuild
new file mode 100644
index 00000000000..232c67d1a14
--- /dev/null
+++ b/media-gfx/kxstitch/kxstitch-2.1.1-r2.ebuild
@@ -0,0 +1,46 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+KDE_HANDBOOK="forceoptional"
+inherit kde5
+
+DESCRIPTION="Program to create cross stitch patterns"
+HOMEPAGE="https://userbase.kde.org/KXStitch";
+SRC_URI="mirror://kde/stable/${PN}/${PV}/${P}.tar.xz"
+
+LICENSE="GPL-2+"
+SLOT="5"
+KEYWORDS="~amd64"
+IUSE=""
+
+BDEPEND="
+       sys-devel/gettext
+"
+DEPEND="
+       $(add_frameworks_dep kcompletion)
+       $(add_frameworks_dep kconfig)
+       $(add_frameworks_dep kconfigwidgets)
+       $(add_frameworks_dep kcoreaddons)
+       $(add_frameworks_dep ki18n)
+       $(add_frameworks_dep kio)
+       $(add_frameworks_dep ktextwidgets)
+       $(add_frameworks_dep kwidgetsaddons)
+       $(add_frameworks_dep kxmlgui)
+       $(add_qt_dep qtgui)
+       $(add_qt_dep qtprintsupport)
+       $(add_qt_dep qtwidgets)
+       $(add_qt_dep qtx11extras)
+       $(add_qt_dep qtxml)
+       media-gfx/imagemagick[cxx]
+       x11-libs/libX11
+"
+RDEPEND="${DEPEND}
+       !media-gfx/kxstitch:4
+"
+
+PATCHES=(
+       "${FILESDIR}/${P}-qt-5.11.patch"
+       "${FILESDIR}/${P}-imagemagick-fix.patch"
+)

Reply via email to