urushima@secom.co.jp (Kenji Urushima) (08/08/90)
Dear Xperts,
Some XPM file utilities by GROUPE BULL was posted
in this news group before.
XPM Read/Write Package for XPM file format:
- int XWritePixmapFile(dpy, cmap, filename, pixmap, w, h);
- int XReadPixmapFile(dpy, d, cmap, filename, w,h, depth,pixmap);
- Pixmap XCreatePixmapFromData(dpy, d, cmap, w, h,
depth, n, c, col, pix);
So, I'm trying to make a application program which
shows XPM file on display, but this doesn't work.
The source code is below.
Something wrong with this program ?
Would you show me any ideas you have,
or show me any XPM application program ?
Thanks in advance,
Kenji.
-----
Kenji Urushima urushima@secom.co.jp (Japan)
SECOM, 6-11-23 Shimorenjaku, Mitaka-si urushima%secom.co.jp@uunet.uu.net (USA)
Tokyo 181 Japan. TEL +81-422-44-9912 urushima%secom.co.jp@mcvax.uucp(Europe)
--------------- cut here ------------ xshowpixmap.c -------------------------
/*
* xshowpixmap - show pixmap file
*
% cc xpm.c xshowpixmap.c -o xshowpixmap -lXaw -lXt -lX11
*
* xpm.c - Read/Write Pixmap File Utility
*/
#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
void
main(argc, argv)
int argc;
char **argv;
{
Widget toplevel, w;
Arg args[10];
Pixmap iconPixmap;
unsigned int iconWidth, iconHeight;
int iconXhot, iconYhot;
toplevel = XtInitialize(NULL, "Bitmap", NULL, 0, &argc,
argv);
if( argc != 2) {
fprintf(stderr, "Usage: %s bitmap_file\n", argv[0]);
exit(1);
}
XReadPixmapFile(XtDisplay(toplevel),
XtWindow(toplevel),
DefaultColormap(XtDisplay(toplevel), XtWindow(toplevel)),
argv[1],
&iconWidth, &iconHeight,
(int)DefaultDepth(XtDisplay(toplevel), XtWindow(toplevel)),
&iconPixmap);
XtSetArg( args[0], XtNbackgroundPixmap, iconPixmap );
XtSetArg( args[1], XtNwidth, iconWidth );
XtSetArg( args[2], XtNheight, iconHeight );
w = XtCreateManagedWidget(argv[0], widgetClass, toplevel, args,
3);
XtRealizeWidget(toplevel);
XtMainLoop();
}daniel@osf.org (Daniel Dardailler) (08/09/90)
> Something wrong with this program ?
First you are trying to access the window of toplevel before it is
realized.
Second you are using a window instead of a screen in your call
to XReadPixmapFile.
Hope this helps.
Daniel Dardailler | OSF/Motif Team
Open Software Foundation | Email : daniel@osf.org
11 Cambridge Center | Phone : (617) 621 8840
CAMBRIDGE, MA 02142 | Fax : (617) 621 0584rune.johansen%odin.re.nta.uninett@NAC.NO (Rune Henning Johansen) (08/09/90)
> From: urushima@secom.co.jp (Kenji Urushima) > Newsgroups: comp.windows.x > So, I'm trying to make a application program which > shows XPM file on display, but this doesn't work. > > Something wrong with this program ? Try the version below! - Rune. --------------- cut here ------------ xshowpixmap.c ------------------------- #include <stdio.h> #include <X11/Xlib.h> #include <X11/Intrinsic.h> #include <X11/StringDefs.h> #include "xpm.h" void main(argc, argv) int argc; char **argv; { Widget toplevel, w; Arg args[10]; Display *display; Window root; int screen; Pixmap iconPixmap; unsigned int iconWidth, iconHeight; toplevel = XtInitialize(NULL, "Bitmap", NULL, 0, &argc, argv); if( argc != 2) { (void)fprintf(stderr, "Usage: %s bitmap_file\n", argv[0]); exit(1); } display = XtDisplay(toplevel); screen = DefaultScreen(display); root = RootWindow(display, screen); if (XReadPixmapFile(display,root, XDefaultColormap(display,screen), argv[1], &iconWidth, &iconHeight, XDefaultDepth(display,screen), &iconPixmap)) { (void)fprintf(stderr, "%s: unable to read Pixmap... [ %s ]\n", argv[0], argv[1]); exit(1); } XtSetArg( args[0], XtNbackgroundPixmap, iconPixmap ); XtSetArg( args[1], XtNwidth, iconWidth ); XtSetArg( args[2], XtNheight, iconHeight ); (void)XtCreateManagedWidget(argv[0], widgetClass, toplevel, args, 3); XtRealizeWidget(toplevel); XtMainLoop(); }