[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kxstitch/release-2.1.0] src: Correct interpretation of alpha values with ImageMagick V7
From: Steve Allewell <null () kde ! org>
Date: 2018-02-02 23:25:20
Message-ID: E1ehkhs-0008A4-8p () code ! kde ! org
[Download RAW message or body]
Git commit 8b067868c544091264967e6717e496ee0bbe1a88 by Steve Allewell.
Committed on 02/02/2018 at 23:23.
Pushed by sallewell into branch 'release-2.1.0'.
Correct interpretation of alpha values with ImageMagick V7
V6 has alpha == 1.0 as transparent, V7 has alpha == 0.0 as transparent
(cherry picked from commit 66f8459123a21698850ec57875ef0ef3f3ef7e2d)
M +3 -1 src/ImportImageDlg.cpp
M +3 -1 src/MainWindow.cpp
https://commits.kde.org/kxstitch/8b067868c544091264967e6717e496ee0bbe1a88
diff --git a/src/ImportImageDlg.cpp b/src/ImportImageDlg.cpp
index 79e8c38..e69a5aa 100644
--- a/src/ImportImageDlg.cpp
+++ b/src/ImportImageDlg.cpp
@@ -307,8 +307,10 @@ void ImportImageDlg::renderPixmap()
#if MagickLibVersion < 0x700
bool hasTransparency = m_convertedImage.matte();
+ double transparent = 1.0;
#else
bool hasTransparency = m_convertedImage.alpha();
+ double transparent = 0.0;
#endif
for (int dy = 0 ; dy < height ; dy++) {
@@ -322,7 +324,7 @@ void ImportImageDlg::renderPixmap()
for (int dx = 0 ; dx < width ; dx++) {
Magick::ColorRGB rgb = m_convertedImage.pixelColor(dx, dy);
- if (hasTransparency && (rgb.alpha() == 1)) {
+ if (hasTransparency && (rgb.alpha() == transparent)) {
//ignore this pixel as it is transparent
} else {
if (!(m_ignoreColor && rgb == m_ignoreColorValue)) {
diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 1d22e63..eebd562 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -545,8 +545,10 @@ void MainWindow::convertImage(const QString &source)
#if MagickLibVersion < 0x700
bool hasTransparency = convertedImage.matte();
+ double transparent = 1.0;
#else
bool hasTransparency = convertedImage.alpha();
+ double transparent = 0.0;
#endif
bool ignoreColor = importImageDlg->ignoreColor();
Magick::Color ignoreColorValue = importImageDlg->ignoreColorValue();
@@ -581,7 +583,7 @@ void MainWindow::convertImage(const QString &source)
for (int dx = 0 ; dx < imageWidth ; dx++) {
Magick::ColorRGB rgb = convertedImage.pixelColor(dx, dy);
- if (hasTransparency && (rgb.alpha() == 1)) {
+ if (hasTransparency && (rgb.alpha() == transparent)) {
// ignore this pixel as it is transparent
} else {
if (!(ignoreColor && (rgb == ignoreColorValue))) {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic