Xmd/libXmd/XmdIcon.c
2023-11-03 21:34:13 -04:00

38 lines
944 B
C

#include <Xmd/Icon.h>
Pixmap _XmdLoadBitmapIcon (Widget widget, unsigned char *bits, int width, int height) {
Pixel fg, bg;
XtVaGetValues (widget,
XmNforeground, &fg,
XmNbackground, &bg,
NULL);
return XCreatePixmapFromBitmapData (
XtDisplay (widget),
RootWindowOfScreen(XtScreen(widget)),
(char *)(bits), width, height,
fg, bg, DefaultDepthOfScreen(XtScreen(widget)));
}
Pixmap XmdReadBitmapFile (Widget widget, const char *filename) {
Pixel fg, bg;
XtVaGetValues (widget,
XmNforeground, &fg,
XmNbackground, &bg,
NULL);
unsigned int width, height;
unsigned char *data;
int garbage;
XReadBitmapFileData (
filename,
&width, &height,
&data,
&garbage, &garbage);
Pixmap result = XCreatePixmapFromBitmapData (
XtDisplay (widget),
RootWindowOfScreen(XtScreen(widget)),
(char *)(data), width, height,
fg, bg, DefaultDepthOfScreen(XtScreen(widget)));
XFree(data);
return result;
}