2 /* This file is part of
3 * =================================================
5 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich.
7 * Copyright 1995-2000 The LyX Team.
9 * This file Copyright 2000 Baruch Even
10 * ================================================= */
13 #pragma implementation
17 #include "XPM_Renderer.h"
19 #include FORMS_H_LOCATION
20 #include XPM_H_LOCATION
24 #include "support/LAssert.h"
30 XPM_Renderer::XPM_Renderer()
34 XPM_Renderer::~XPM_Renderer()
37 bool XPM_Renderer::renderImage()
44 Display * display = fl_get_display();
47 #warning This might be a dirty thing, but I dont know any other solution.
48 Screen * screen = DefaultScreenOfDisplay(display);
50 int status = XpmReadFileToPixmap(
52 XRootWindowOfScreen(screen),
53 const_cast<char *>(getFilename().c_str()),
54 &pixmap, &mask, &attrib);
56 if (status != XpmSuccess) {
57 lyxerr << "Error reading XPM file '"
58 << XpmGetErrorString(status)
63 // This should have been set by the XpmReadFileToPixmap call!
64 Assert(attrib.valuemask & XpmSize);
66 setPixmap(pixmap, attrib.width, attrib.height);
68 XpmFreeAttributes(&attrib);
73 bool XPM_Renderer::isImageFormatOK(string const & filename) const
75 std::ifstream is(filename.c_str(), ios::in);
77 // The signature of the file without the spaces.
78 static const char str[] = "/*XPM*/";
79 const char * ptr = str;
89 } while (*ptr != '\0');