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"
31 XPM_Renderer::XPM_Renderer()
36 bool XPM_Renderer::renderImage()
43 Display * display = fl_get_display();
46 #warning This might be a dirty thing, but I dont know any other solution.
47 Screen * screen = DefaultScreenOfDisplay(display);
49 int status = XpmReadFileToPixmap(
51 XRootWindowOfScreen(screen),
52 const_cast<char *>(getFilename().c_str()),
53 &pixmap, &mask, &attrib);
55 if (status != XpmSuccess) {
56 lyxerr << "Error reading XPM file '"
57 << XpmGetErrorString(status)
62 // This should have been set by the XpmReadFileToPixmap call!
63 Assert(attrib.valuemask & XpmSize);
65 setPixmap(pixmap, attrib.width, attrib.height);
67 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');