help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inserting images in light and dark background


From: Oliver Scholz
Subject: Re: inserting images in light and dark background
Date: Fri, 23 Jan 2004 12:15:49 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (windows-nt)

Miguel Frasson <frasson@enquist.math.leidenuniv.nl> writes:

> Hi
>
> I have a set of icon sized images in xpm format. They are grayscale, with
> white background and black is the "foreground" color (gray in the middle).
>
> They are very nice to insert in a buffer, but if one uses black
> background (like me!!), they are terrible. I wnat to white a elisp program
> to display them, no matter background.
>
> The best solution would be able to display them in reverse-video if the
> background is black. Is thee a way to do it?

I am not aware of any functionality like that. However, the XPM
format provides a means to change the colours of an image at
run-time. Take this example:


(defvar my-xpm "/* XPM */
static char * my_xpm[] = {
\"10 10 3 1\",
\". s back c White\",
\"o s medium c Grey50\",
\"# s fore c Black\",
\"....##....\",
\"..##..##..\",
\".#......#.\",
\"#...oo...#\",
\"#..oooo..#\",
\"#..oooo..#\",
\"#...oo...#\",
\".#......#.\",
\"..##..##..\",
\"....##....\"};")

In the colour specification the key-symbol "c" specifies the colour
to use on a colour display. The "s" symbol specifies a symbol to
reference the according pixels and assign a different colour to them
programmatically. This will insert the image with the colours
specified by "c":

(insert-image (create-image my-xpm 'xpm t))

But this will insert the image with different colours:

(insert-image (create-image my-xpm 'xpm t
                            :color-symbols '(("back" . "black")
                                             ("medium" . "darkslateblue")
                                             ("fore" . "white"))))


If you can't change the XPM images, then the best I can think of is to
make the background transparent:

(insert-image (create-image my-xpm 'xpm t
                            :mask '(heuristic t)))

Even if you can change the XPM files, it is probably a good idea
anyways to use a transparent background instead of white. Your users
could have a light grey background, for instance. Use the special
symbol "None" in the XPM file for this, e.g. in the example above
change ". s back c White", to ". s back c None".


    Oliver
--
4 Pluviôse an 212 de la Révolution
Liberté, Egalité, Fraternité!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]