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
This commit is contained in:
Angus Leeming 2001-09-21 15:17:01 +00:00
parent 414b45b140
commit 4851d24977
2 changed files with 34 additions and 4 deletions

View 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>

View 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;
}