scx/c/xlib/pixmap.c

103 lines
3.4 KiB
C
Raw Normal View History

/* Copyright 2001-2003 by Norbert Freudemann, David Frese */
2001-05-08 10:21:00 -04:00
#include "xlib.h"
2001-05-08 10:21:00 -04:00
s48_value scx_Create_Pixmap(s48_value display, s48_value drawable, s48_value w,
s48_value h, s48_value depth) {
2003-05-04 11:19:39 -04:00
Pixmap pm;
2003-05-02 10:58:17 -04:00
S48_DECLARE_GC_PROTECT_5(display, drawable, w, h, depth);
2003-05-04 11:19:39 -04:00
pm = XCreatePixmap(scx_extract_display(display),
scx_extract_drawable(drawable),
(int)s48_extract_integer(w),
(int)s48_extract_integer(h),
(int)s48_extract_integer(depth));
2003-05-02 10:58:17 -04:00
S48_GC_RETURN(scx_enter_pixmap(pm));
2001-05-08 10:21:00 -04:00
}
s48_value scx_Free_Pixmap(s48_value display, s48_value pixmap) {
2003-05-02 10:58:17 -04:00
S48_DECLARE_GC_PROTECT_2(display, pixmap);
XFreePixmap(scx_extract_display(display), scx_extract_pixmap(pixmap));
2003-05-02 10:58:17 -04:00
S48_GC_RETURN(S48_UNSPECIFIC);
2001-05-08 10:21:00 -04:00
}
s48_value scx_Read_Bitmap_File(s48_value display, s48_value drawable,
s48_value filename) {
2001-07-16 09:22:50 -04:00
unsigned width, height;
int res, xhot, yhot;
Pixmap bitmap;
s48_value ret = S48_FALSE;
2003-05-02 10:58:17 -04:00
S48_DECLARE_GC_PROTECT_4(display, drawable, filename, ret);
res = XReadBitmapFile(scx_extract_display(display),
scx_extract_drawable(drawable),
s48_extract_string(filename), &width, &height, &bitmap,
&xhot, &yhot);
if (res != BitmapSuccess)
2003-05-02 10:58:17 -04:00
S48_GC_RETURN(s48_enter_integer(res));
ret = s48_cons(s48_enter_integer(yhot), S48_NULL);
ret = s48_cons(s48_enter_integer(xhot), ret);
ret = s48_cons(s48_enter_integer(height), ret);
ret = s48_cons(s48_enter_integer(width), ret);
ret = s48_cons(scx_enter_pixmap(bitmap), ret);
2003-05-02 10:58:17 -04:00
S48_GC_RETURN(ret);
2001-05-08 10:21:00 -04:00
}
s48_value scx_Write_Bitmap_File(s48_value display, s48_value filename,
s48_value bitmap, s48_value w, s48_value h,
s48_value x, s48_value y) {
2001-07-16 09:22:50 -04:00
int ret;
2003-05-02 10:58:17 -04:00
S48_DECLARE_GC_PROTECT_7(display, filename, bitmap, w, h, x, y);
ret = XWriteBitmapFile(scx_extract_display(display),
s48_extract_string(filename),
scx_extract_pixmap(bitmap),
(int)s48_extract_integer(w),
(int)s48_extract_integer(h),
(int)s48_extract_integer(x),
(int)s48_extract_integer(y));
2003-05-02 10:58:17 -04:00
S48_GC_RETURN(s48_enter_integer(ret));
2001-05-08 10:21:00 -04:00
}
s48_value scx_Create_Bitmap_From_Data(s48_value display, s48_value drawable,
s48_value data, s48_value w,
s48_value h) {
2003-05-02 10:58:17 -04:00
Pixmap pm;
S48_DECLARE_GC_PROTECT_5(display, drawable, data, w, h);
pm = XCreateBitmapFromData(scx_extract_display(display),
scx_extract_drawable(drawable),
s48_extract_string(data),
s48_extract_integer(w),
s48_extract_integer(h));
S48_GC_RETURN(scx_enter_pixmap(pm));
}
s48_value scx_Create_Pixmap_From_Bitmap_Data(s48_value display,
s48_value drawable,
s48_value data,
s48_value w,s48_value h,
s48_value f, s48_value b,
s48_value depth) {
2003-05-02 10:58:17 -04:00
Pixmap pm;
S48_DECLARE_GC_PROTECT_8(display, drawable, data, w, h, f, b, depth);
pm = XCreatePixmapFromBitmapData(scx_extract_display(display),
scx_extract_drawable(drawable),
s48_extract_string(data),
(int)s48_extract_integer(w),
(int)s48_extract_integer(h),
scx_extract_pixel(f),
scx_extract_pixel(b),
(int)s48_extract_integer(depth));
S48_GC_RETURN(scx_enter_pixmap(pm));
}
2001-07-09 09:39:59 -04:00
void scx_init_pixmap(void) {
S48_EXPORT_FUNCTION(scx_Free_Pixmap);
S48_EXPORT_FUNCTION(scx_Create_Pixmap);
S48_EXPORT_FUNCTION(scx_Read_Bitmap_File);
S48_EXPORT_FUNCTION(scx_Write_Bitmap_File);
S48_EXPORT_FUNCTION(scx_Create_Bitmap_From_Data);
S48_EXPORT_FUNCTION(scx_Create_Pixmap_From_Bitmap_Data);
2001-07-09 09:39:59 -04:00
}
2001-07-16 09:22:50 -04:00