From 70a852b5e15325c48c753fa6b37c18030f88c310 Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Fri, 21 Sep 2001 10:52:48 +0000 Subject: [PATCH] If a pixmap contains a transparent colour, then set it to the colour of the background. (With thanks to John Levon.) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2780 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/graphics/ChangeLog | 5 +++++ src/graphics/ImageLoaderXPM.C | 19 +++++++++++++++---- src/insets/ChangeLog | 5 +++++ src/insets/insetgraphics.C | 6 ------ 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/graphics/ChangeLog b/src/graphics/ChangeLog index 4f767f6fb0..d8b4a1b8aa 100644 --- a/src/graphics/ChangeLog +++ b/src/graphics/ChangeLog @@ -1,3 +1,8 @@ +2001-09-21 Angus Leeming + + * ImageLoaderXPM.C (runImageLoader): If the pixmap contains a + transparent colour, then set it to the colour of the background. + 2001-09-20 Angus Leeming * GraphicsCacheItem.C (convertImage): only convert if "from" and "to" diff --git a/src/graphics/ImageLoaderXPM.C b/src/graphics/ImageLoaderXPM.C index 6d1ad4117a..47322bab08 100644 --- a/src/graphics/ImageLoaderXPM.C +++ b/src/graphics/ImageLoaderXPM.C @@ -13,6 +13,7 @@ #include #include "ImageLoaderXPM.h" +#include "ColorHandler.h" #include "frontends/support/LyXImage.h" #include "frontends/GUIRunTime.h" #include "support/filetools.h" @@ -66,11 +67,21 @@ ImageLoaderXPM::runImageLoader(string const & filename) Pixmap pixmap; Pixmap mask; + + // If the pixmap contains a transparent colour, then set it to the + // colour of the background (Angus 21 Sep 2001) + XpmColorSymbol xpm_col; + xpm_col.name = 0; + xpm_col.value = "none"; + xpm_col.pixel = lyxColorHandler->colorPixel(LColor::graphicsbg); + XpmAttributes attrib; - - attrib.valuemask = XpmCloseness; + attrib.valuemask = XpmCloseness | XpmColorSymbols; attrib.closeness = 10000; - + attrib.valuemask = XpmColorSymbols; + attrib.numsymbols = 1; + attrib.colorsymbols = &xpm_col; + int status = XpmReadFileToPixmap( display, XRootWindowOfScreen(screen), @@ -83,7 +94,7 @@ ImageLoaderXPM::runImageLoader(string const & filename) << endl; return ErrorWhileLoading; } - + // This should have been set by the XpmReadFileToPixmap call! lyx::Assert(attrib.valuemask & XpmSize); diff --git a/src/insets/ChangeLog b/src/insets/ChangeLog index e4dd04fd4b..c25a5f0aaf 100644 --- a/src/insets/ChangeLog +++ b/src/insets/ChangeLog @@ -1,3 +1,8 @@ +2001-09-21 Angus Leeming + + * insetgraphics.C (draw): remove the previous change. Right place is in + imageLoaderXPM.C. + 2001-09-18 Angus Leeming * figinset.C (runqueue): diff --git a/src/insets/insetgraphics.C b/src/insets/insetgraphics.C index 2285db34e0..7db9d2a878 100644 --- a/src/insets/insetgraphics.C +++ b/src/insets/insetgraphics.C @@ -284,12 +284,6 @@ void InsetGraphics::draw(BufferView * bv, LyXFont const & font, // we draw just a rectangle. if (imageLoaded) { - // Draw a ractangle with the specified color. If the image is - // transparent, this will shine through. - paint.fillRectangle(old_x + 2, baseline - lascent, - lwidth - 4, lascent + ldescent, - LColor::graphicsbg); - paint.image(old_x + 2, baseline - lascent, lwidth - 4, lascent + ldescent, cacheHandle->getImage()); -- 2.39.2