Gentoo Archives: gentoo-commits

From: Andreas Sturmlechner <asturm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: media-gfx/kxstitch/files/, media-gfx/kxstitch/
Date: Wed, 08 May 2019 17:05:26
Message-Id: 1557335014.68d2bc286976cef43b53bf84573e6d15a75404e0.asturm@gentoo
1 commit: 68d2bc286976cef43b53bf84573e6d15a75404e0
2 Author: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
3 AuthorDate: Sun May 5 21:01:17 2019 +0000
4 Commit: Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
5 CommitDate: Wed May 8 17:03:34 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=68d2bc28
7
8 media-gfx/kxstitch: Fix for importing images for V6 of ImageMagick
9
10 See also: https://mail.kde.org/pipermail/kxstitch/2018-October/000006.html
11
12 Reported-by: Dave Armstrong
13 Package-Manager: Portage-2.3.66, Repoman-2.3.12
14 Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>
15
16 .../files/kxstitch-2.1.1-imagemagick-fix.patch | 99 ++++++++++++++++++++++
17 media-gfx/kxstitch/kxstitch-2.1.1-r2.ebuild | 46 ++++++++++
18 2 files changed, 145 insertions(+)
19
20 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
21 new file mode 100644
22 index 00000000000..bf8c5e14096
23 --- /dev/null
24 +++ b/media-gfx/kxstitch/files/kxstitch-2.1.1-imagemagick-fix.patch
25 @@ -0,0 +1,99 @@
26 +From 75a129d3c2f21914a47b970df822e485aca625ac Mon Sep 17 00:00:00 2001
27 +From: Steve Allewell <steve.allewell@×××××.com>
28 +Date: Sun, 11 Nov 2018 15:48:50 +0000
29 +Subject: Fix for importing images for V6 of ImageMagick
30 +
31 +The getPixelColor in V6 of ImageMagick does not appear to return the
32 +same information as in V7, consequently importing images has resulted in
33 +a black image when using V6 of ImageMagick. This fix reverts the change
34 +made in commit 295773f44bfda1227d85edf065a8de14dc889159 when using V6.
35 +
36 +Big thanks to Sean Enck for reporting and helping diagnose the problem.
37 +---
38 + src/ImportImageDlg.cpp | 16 ++++++++++++++++
39 + src/MainWindow.cpp | 17 +++++++++++++++++
40 + 2 files changed, 33 insertions(+)
41 +
42 +diff --git a/src/ImportImageDlg.cpp b/src/ImportImageDlg.cpp
43 +index e6396c6..340ff1d 100644
44 +--- a/src/ImportImageDlg.cpp
45 ++++ b/src/ImportImageDlg.cpp
46 +@@ -391,9 +391,21 @@ void ImportImageDlg::renderPixmap()
47 + QProgressDialog progress(i18n("Rendering preview"), i18n("Cancel"), 0, pixelCount, this);
48 + progress.setWindowModality(Qt::WindowModal);
49 +
50 ++/*
51 ++ * ImageMagick prior to V7 used matte (opacity) to determine if an image has transparency.
52 ++ * 0.0 for transparent to 1.0 for opaque
53 ++ *
54 ++ * ImageMagick V7 now uses alpha (transparency).
55 ++ * 1.0 for transparent to 0.0 for opaque
56 ++ *
57 ++ * Access to pixels has changed too, V7 can use pixelColor to access the color of a particular
58 ++ * pixel, but although this was available in V6, it doesn't appear to produce the same result
59 ++ * and has resulted in black images when importing.
60 ++ */
61 + #if MagickLibVersion < 0x700
62 + bool hasTransparency = m_convertedImage.matte();
63 + double transparent = 1.0;
64 ++ const Magick::PixelPacket *pixels = m_convertedImage.getConstPixels(0, 0, width, height);
65 + #else
66 + bool hasTransparency = m_convertedImage.alpha();
67 + double transparent = 0.0;
68 +@@ -408,7 +420,11 @@ void ImportImageDlg::renderPixmap()
69 + }
70 +
71 + for (int dx = 0 ; dx < width ; dx++) {
72 ++#if MagickLibVersion < 0x700
73 ++ Magick::ColorRGB rgb = Magick::Color(*pixels++);
74 ++#else
75 + Magick::ColorRGB rgb = m_convertedImage.pixelColor(dx, dy);
76 ++#endif
77 +
78 + if (hasTransparency && (rgb.alpha() == transparent)) {
79 + //ignore this pixel as it is transparent
80 +diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
81 +index 1f12f5b..ecf552a 100644
82 +--- a/src/MainWindow.cpp
83 ++++ b/src/MainWindow.cpp
84 +@@ -541,13 +541,26 @@ void MainWindow::convertImage(const QString &source)
85 +
86 + bool useFractionals = importImageDlg->useFractionals();
87 +
88 ++/*
89 ++ * ImageMagick prior to V7 used matte (opacity) to determine if an image has transparency.
90 ++ * 0.0 for transparent to 1.0 for opaque
91 ++ *
92 ++ * ImageMagick V7 now uses alpha (transparency).
93 ++ * 1.0 for transparent to 0.0 for opaque
94 ++ *
95 ++ * Access to pixels has changed too, V7 can use pixelColor to access the color of a particular
96 ++ * pixel, but although this was available in V6, it doesn't appear to produce the same result
97 ++ * and has resulted in black images when importing.
98 ++ */
99 + #if MagickLibVersion < 0x700
100 + bool hasTransparency = convertedImage.matte();
101 + double transparent = 1.0;
102 ++ const Magick::PixelPacket *pixels = convertedImage.getConstPixels(0, 0, imageWidth, imageHeight);
103 + #else
104 + bool hasTransparency = convertedImage.alpha();
105 + double transparent = 0.0;
106 + #endif
107 ++
108 + bool ignoreColor = importImageDlg->ignoreColor();
109 + Magick::Color ignoreColorValue = importImageDlg->ignoreColorValue();
110 +
111 +@@ -579,7 +592,11 @@ void MainWindow::convertImage(const QString &source)
112 + }
113 +
114 + for (int dx = 0 ; dx < imageWidth ; dx++) {
115 ++#if MagickLibVersion < 0x700
116 ++ Magick::ColorRGB rgb = Magick::Color(*pixels++); // is this a memory leak
117 ++#else
118 + Magick::ColorRGB rgb = convertedImage.pixelColor(dx, dy);
119 ++#endif
120 +
121 + if (hasTransparency && (rgb.alpha() == transparent)) {
122 + // ignore this pixel as it is transparent
123 +--
124 +cgit v1.1
125
126 diff --git a/media-gfx/kxstitch/kxstitch-2.1.1-r2.ebuild b/media-gfx/kxstitch/kxstitch-2.1.1-r2.ebuild
127 new file mode 100644
128 index 00000000000..232c67d1a14
129 --- /dev/null
130 +++ b/media-gfx/kxstitch/kxstitch-2.1.1-r2.ebuild
131 @@ -0,0 +1,46 @@
132 +# Copyright 1999-2019 Gentoo Authors
133 +# Distributed under the terms of the GNU General Public License v2
134 +
135 +EAPI=7
136 +
137 +KDE_HANDBOOK="forceoptional"
138 +inherit kde5
139 +
140 +DESCRIPTION="Program to create cross stitch patterns"
141 +HOMEPAGE="https://userbase.kde.org/KXStitch"
142 +SRC_URI="mirror://kde/stable/${PN}/${PV}/${P}.tar.xz"
143 +
144 +LICENSE="GPL-2+"
145 +SLOT="5"
146 +KEYWORDS="~amd64"
147 +IUSE=""
148 +
149 +BDEPEND="
150 + sys-devel/gettext
151 +"
152 +DEPEND="
153 + $(add_frameworks_dep kcompletion)
154 + $(add_frameworks_dep kconfig)
155 + $(add_frameworks_dep kconfigwidgets)
156 + $(add_frameworks_dep kcoreaddons)
157 + $(add_frameworks_dep ki18n)
158 + $(add_frameworks_dep kio)
159 + $(add_frameworks_dep ktextwidgets)
160 + $(add_frameworks_dep kwidgetsaddons)
161 + $(add_frameworks_dep kxmlgui)
162 + $(add_qt_dep qtgui)
163 + $(add_qt_dep qtprintsupport)
164 + $(add_qt_dep qtwidgets)
165 + $(add_qt_dep qtx11extras)
166 + $(add_qt_dep qtxml)
167 + media-gfx/imagemagick[cxx]
168 + x11-libs/libX11
169 +"
170 +RDEPEND="${DEPEND}
171 + !media-gfx/kxstitch:4
172 +"
173 +
174 +PATCHES=(
175 + "${FILESDIR}/${P}-qt-5.11.patch"
176 + "${FILESDIR}/${P}-imagemagick-fix.patch"
177 +)