wong@cathedral.cerc.wvu.wvnet.edu (Dennis Hiulum Wong) (08/15/90)
I have trouble using bitmap in Label widget. I used
XReadBitmapFile to create a pixmap from a bitmap file,
and then used XmNlabelPixmap to specify the pixmap.
The following is the code segmant for it. I appreciate
it if someone can point out th error or provide a
better solution for me. Thanks in advance.
-- Dennis
E-mail: wong@cerc.wvu.wvnet.edu
******************************************************
Pixmap pixmap;
i = 0;
label_w = XtCreateManagedWidget("BitmapLabel",
xmLabelWidgetClass, parent_win, (ArgList)args, i);
read_bitmap(label_w, "bitmap_file.xbm", &pixmap, &w, &h);
i = 0;
XtSetArg(args[i], XmNlabelType, XmPIXMAP); i++;
XtSetArg(args[i], XmNlabelPixmap, pixmap); i++;
XtSetValues(label_w, (ArgList)args, i);
--------------------------------------------------------
read_bitmap(w, bitmapFile, bitmap, width, height)
Widget w;
char *bitmapFile;
Pixmap *bitmap;
Dimension *width, *height;
{
int x, y, error;
unsigned int i, j;
error = XReadBitmapFile(XtDisplay(w), RootWindowOfScreen(XtScreen(w)),
bitmapFile, &i, &j, bitmap, &x, &y);
*width = (Dimension)i;
*height = (Dimension)j;
if (error == BitmapFileInvalid)
printf("#Error, file %s contains invalid bitmap data.\n",
bitmapFile);
else if (error == BitmapOpenFailed)
printf("#Error, file %s could not be opened.\n",
bitmapFile);
else if (error == BitmapNoMemory)
printf("#Error, not enough memory to allocate pixmap.\n");
else if (error != BitmapSuccess)
printf("#Error in reading bitmap.\n");
return(error);
}
**********************************************************