summaryrefslogtreecommitdiffstats
path: root/src/display/grayscale.cpp
diff options
context:
space:
mode:
authorAndrew Higginson <at.higginson@gmail.com>2011-12-27 21:04:47 +0000
committerAndrew <at.higginson@gmail.com>2011-12-27 21:04:47 +0000
commit80960b623a99aae1402ab651b2974ef544ed3b03 (patch)
treeba49d42c2789e9e11f805e2d5263e10f9fedeef8 /src/display/grayscale.cpp
parenttry to fix bug (diff)
parentGDL: Cherry-pick upstream patch 73852 (2011-03-23) - Add missing return value. (diff)
downloadinkscape-80960b623a99aae1402ab651b2974ef544ed3b03.tar.gz
inkscape-80960b623a99aae1402ab651b2974ef544ed3b03.zip
merged with trunk so I can build again...
(bzr r10092.1.36)
Diffstat (limited to 'src/display/grayscale.cpp')
-rw-r--r--src/display/grayscale.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/display/grayscale.cpp b/src/display/grayscale.cpp
index 37f2b255c..f59cf6d23 100644
--- a/src/display/grayscale.cpp
+++ b/src/display/grayscale.cpp
@@ -21,14 +21,22 @@
namespace Grayscale {
+/* Original values from Johan:
+const float red_factor = 0.3;
+const float green_factor = 0.59;
+const float blue_factor = 0.11;
+*/
+
+// Values below are from the SVG specification
+const float red_factor = 0.2125;
+const float green_factor = 0.7154;
+const float blue_factor = 0.0721;
+
guint32 process(guint32 rgba) {
return process(SP_RGBA32_R_U(rgba), SP_RGBA32_G_U(rgba), SP_RGBA32_B_U(rgba), SP_RGBA32_A_U(rgba));
}
guint32 process(guchar r, guchar g, guchar b, guchar a) {
- float red_factor = 0.3;
- float green_factor = 0.59;
- float blue_factor = 0.11;
/** To reduce banding in gradients, this calculation is tweaked a bit
* by outputing blue+1 or red+1 or both. The luminance is calculated
@@ -65,7 +73,8 @@ guchar luminance(guchar r, guchar g, guchar b) {
return luminance & 0xff;
}
-/** @brief Use this method if there is no other way to find out if grayscale view or not
+/**
+ * Use this method if there is no other way to find out if grayscale view or not.
*
* In some cases, the choice between normal or grayscale is so deep in the code hierarchy,
* that it is not possible to determine whether grayscale is desired or not, without using
@@ -74,7 +83,7 @@ guchar luminance(guchar r, guchar g, guchar b) {
*/
bool activeDesktopIsGrayscale() {
if (SP_ACTIVE_DESKTOP) {
- return (SP_ACTIVE_DESKTOP->getColorMode() == Inkscape::COLORRENDERMODE_GRAYSCALE);
+ return (SP_ACTIVE_DESKTOP->getColorMode() == Inkscape::COLORMODE_GRAYSCALE);
} else {
return false;
}