From 4851d249775693a3d0bad3b5d471b09a4628f892 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Fri, 21 Sep 2001 15:17:01 +0000 Subject: [PATCH] Take account of the monochrome, grayscale of color preferences option. (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 | 2 ++ src/graphics/ImageLoaderXPM.C | 36 +++++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/graphics/ChangeLog b/src/graphics/ChangeLog index d8b4a1b8aa..95b60e1b6f 100644 --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -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 diff --git a/src/graphics/ImageLoaderXPM.C b/src/graphics/ImageLoaderXPM.C index 47322bab08..37e66132ee 100644 --- a/src/graphics/ImageLoaderXPM.C +++ b/src/graphics/ImageLoaderXPM.C @@ -14,6 +14,7 @@ #include #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; } -- 2.39.2