2023-11-03 21:59:24 +00:00
|
|
|
#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)));
|
|
|
|
}
|
2023-11-04 01:34:13 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|