On Thursday 20 September 2001 14:28, John Levon wrote:
> On Thu, Sep 20, 2001 at 02:28:24PM +0100, Angus Leeming wrote:
> 
> > This patch works like a charm with the (old) figinset. When testing
> > the graphics inset, however, I find that colour "None" in an XPM file
> > is displayed as black. I have no idea why. This appears to be true of
> > some other graphics viewers also. E.g., KDE 2's pixie displays "None"
> > as black but the venerable xv works fine.
> 
> It's because we need to do the equivalent of :
> 
>         xpm_col.name = NULL;
>         xpm_col.value = "none";
>         xpm_col.pixel = backgroundcolor;
>         xpm_attr.valuemask = XpmColorSymbols;
>         xpm_attr.numsymbols = 1;
>         xpm_attr.colorsymbols = &xpm_col;
>         XpmCreatePixmapFromData(display, RootWindow(display,screen), 
nofill_xpm, &nofill, &dummy, &xpm_attr);
> 
> to replace the none pixel with our background colour. Xpm is pretty stupid.
> 
> regards
> john

Ahhh. Thanks John.

We load the pixmap to the screen direct from file:

ImageLoaderXPM::runImageLoader(string const & filename)
{
        Display * display = GUIRunTime::x11Display();

        //(BE 2000-08-05)
        // This might be a dirty thing, but I dont know any other solution.
        Screen * screen = ScreenOfDisplay(display, GUIRunTime::x11Screen());

        Pixmap pixmap;
        Pixmap mask;
        XpmAttributes attrib;
        
        attrib.valuemask = XpmCloseness;
        attrib.closeness = 10000;
        
        int status = XpmReadFileToPixmap(
                        display, 
                        XRootWindowOfScreen(screen), 
                        const_cast<char *>(filename.c_str()), 
                        &pixmap, &mask, &attrib);


        ...
}

so this is where we should apply your "repair"? Ie, pass runImageLoader the 
background pixel colour and set the attributes there.

Figinset does things differently. Ie, it modifies an already loaded pixmap. 
Maybe this is better for us, because if we load an image and discover the 
background colour is bad, we'll want to change that background and see an 
effect.

Can we create, therefore, a
ImageLoaderXPM::setBackgroundColor()
that does the same as figinset in this regard?

Note that I have NO X skills so I'll need you to (at the very least) hold my 
hand here!

Angus

This is how it's done in figinset:

                        unsigned long background_pixel =
                                lyxColorHandler->colorPixel(LColor::graphicsbg);

                        switch (p->data->flags & 3) {
                        case 0: t3 << 'H'; break; // Hidden
                        case 1: t3 << 'M'; break; // Mono
                        case 2: t3 << 'G'; break; // Gray
                        case 3:
                                if (color_visual) 
                                        t3 << 'C'; // Color
                                else 
                                        t3 << 'G'; // Gray
                                break;
                        }
        
                        t3 << ' ' << 
BlackPixelOfScreen(DefaultScreenOfDisplay(tempdisp))
                           << ' ' << background_pixel;

                        XGrabServer(tempdisp);
                        XChangeProperty(tempdisp, 
                                        fl_get_canvas_id(figinset_canvas),
                                        XInternAtom(tempdisp,
                                                    "GHOSTVIEW_COLORS", false),
                                        XInternAtom(tempdisp, "STRING", false),
                                        8, PropModeReplace, 
                                        reinterpret_cast<unsigned 
char*>(const_cast<char*>(t3.str().c_str())),
                                        int(t3.str().size()));
                        XUngrabServer(tempdisp);
                        XFlush(tempdisp);

So, it would appear, this is also the time to specify whether the image is 
displayed in monochrome, grayscale or colour.





Reply via email to