scx/c/xlib/colormap.c

49 lines
1.2 KiB
C
Raw Normal View History

2001-05-08 10:21:00 -04:00
#include "xlib.h"
#include "scheme48.h"
2001-05-08 10:21:00 -04:00
s48_value Free_Colormap (s48_value Xcolormap, s48_value Xdisplay) {
XFreeColormap(EXTRACT_DISPLAY(Xdisplay), EXTRACT_COLORMAP(Xcolormap));
return S48_UNSPECIFIC;
}
2001-05-08 10:21:00 -04:00
s48_value Alloc_Color(s48_value Xcolormap, s48_value Xcolor,
s48_value Xdisplay) {
XColor* cp = EXTRACT_COLOR(Xcolor);
2001-05-08 10:21:00 -04:00
if (!XAllocColor(EXTRACT_DISPLAY(Xdisplay), EXTRACT_COLORMAP(Xcolormap), cp))
return S48_FALSE;
else
return ENTER_PIXEL(cp->pixel);
}
2001-05-08 10:21:00 -04:00
s48_value Alloc_Named_Color(s48_value Xcolormap, s48_value color_name,
s48_value Xdisplay) {
XColor screen, exact;
int r;
s48_value ret;
2001-05-08 10:21:00 -04:00
S48_DECLARE_GC_PROTECT(1);
2001-05-08 10:21:00 -04:00
r = XAllocNamedColor (EXTRACT_DISPLAY(Xdisplay), EXTRACT_COLORMAP(Xcolormap),
s48_extract_string(color_name),
&screen, &exact);
2001-05-08 10:21:00 -04:00
if (!r) ret = S48_FALSE;
else {
S48_GC_PROTECT_1(ret);
ret = s48_cons(Int_Extract_RGB_Values(exact), S48_NULL);
ret = s48_cons(Int_Extract_RGB_Values(screen), ret);
ret = s48_cons(ENTER_PIXEL(screen.pixel), ret);
}
2001-05-08 10:21:00 -04:00
S48_GC_UNPROTECT();
return ret;
2001-05-08 10:21:00 -04:00
}
void s48_init_colormap(void) {
S48_EXPORT_FUNCTION(Free_Colormap);
S48_EXPORT_FUNCTION(Alloc_Color);
S48_EXPORT_FUNCTION(Alloc_Named_Color);
2001-05-08 10:21:00 -04:00
}