* Re: inserting images in light and dark background
2004-01-20 17:18 inserting images in light and dark background Miguel Frasson
@ 2004-01-23 11:15 ` Oliver Scholz
0 siblings, 0 replies; 2+ messages in thread
From: Oliver Scholz @ 2004-01-23 11:15 UTC (permalink / raw)
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é!
^ permalink raw reply [flat|nested] 2+ messages in thread