]> git.lyx.org Git - features.git/commitdiff
Take account of the monochrome, grayscale of color preferences option.
authorAngus Leeming <leeming@lyx.org>
Fri, 21 Sep 2001 15:17:01 +0000 (15:17 +0000)
committerAngus Leeming <leeming@lyx.org>
Fri, 21 Sep 2001 15:17:01 +0000 (15:17 +0000)
(Doesn't seem to work on my box: is this because I have a TrueType
display?)

Feedback appreciated.
Angus

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2783 a592a061-630c-0410-9148-cb99ea01b6c8

src/graphics/ChangeLog
src/graphics/ImageLoaderXPM.C

index d8b4a1b8aad224f154db6d9b83030b6475f7c2ce..95b60e1b6f50e5eef7201a27b5f9bd0ce696aa46 100644 (file)
@@ -2,6 +2,8 @@
 
        * ImageLoaderXPM.C (runImageLoader): If the pixmap contains a
        transparent colour, then set it to the colour of the background.
+       Also take account of the monochrome, grayscale of color
+       preferences option.
 
 2001-09-20  Angus Leeming  <a.leeming@ic.ac.uk>
 
index 47322bab088cf602ff78838ec78f19baf61a1faa..37e66132eec1187e94526450f71e842b25642300 100644 (file)
@@ -14,6 +14,7 @@
 #include <config.h>
 #include "ImageLoaderXPM.h"
 #include "ColorHandler.h"
+#include "lyxrc.h"
 #include "frontends/support/LyXImage.h"
 #include "frontends/GUIRunTime.h"
 #include "support/filetools.h"
@@ -76,12 +77,39 @@ ImageLoaderXPM::runImageLoader(string const & filename)
        xpm_col.pixel = lyxColorHandler->colorPixel(LColor::graphicsbg);
 
        XpmAttributes attrib;
-       attrib.valuemask = XpmCloseness | XpmColorSymbols;
+       attrib.valuemask = XpmCloseness | XpmColorSymbols | XpmColorKey;
+
        attrib.closeness = 10000;
-       attrib.valuemask = XpmColorSymbols;
+
        attrib.numsymbols = 1;
        attrib.colorsymbols = &xpm_col;
 
+       // Set color_key to monochrome, grayscale or color
+       // (Angus 21 Sep 2001)
+       int color_key = 0;
+       if (lyxrc.display_graphics == "color") {
+               color_key = XPM_COLOR;
+
+       } else if (lyxrc.display_graphics == "gray") {
+               color_key = XPM_GRAY;
+
+       } else if (lyxrc.display_graphics == "mono") {
+               color_key = XPM_MONO;
+       }
+
+       // If setting color_key failed, then fail gracefully!
+       if (color_key != 0) {
+               attrib.valuemask = attrib.valuemask | XpmColorKey;
+               attrib.color_key = color_key;
+
+       } else {
+               lyxerr << "Warning in ImageLoaderXPM::runImageLoader"
+                      << "lyxrc.display_graphics == \""
+                      << lyxrc.display_graphics
+                      << "\""
+                      << endl;
+       }               
+
        int status = XpmReadFileToPixmap(
                        display, 
                        XRootWindowOfScreen(screen), 
@@ -90,8 +118,8 @@ ImageLoaderXPM::runImageLoader(string const & filename)
 
        if (status != XpmSuccess) {
                lyxerr << "Error reading XPM file '" 
-                       << XpmGetErrorString(status) << "'"
-                       << endl;
+                      << XpmGetErrorString(status) << "'"
+                      << endl;
                return ErrorWhileLoading;
        }