void iupdrvImageGetRawData(void* handle, unsigned char* imgdata) { Pixmap pixmap = (Pixmap)handle; int w, h, y, x, bpp; XImage *xi; if (!iupdrvImageGetInfo(handle, &w, &h, &bpp)) return; if (bpp==8) return; xi = XGetImage(iupmot_display, pixmap, 0, 0, w, h, ULONG_MAX, ZPixmap); if (xi) { /* planes are separated in imgdata */ int planesize = w*h; unsigned char *r = imgdata, *g = imgdata+planesize, *b = imgdata+2*planesize; for (y=0; y<h; y++) { int lineoffset = (h-1 - y)*w; /* imgdata is bottom up */ for (x=0; x<w; x++) { iupmotColorGetRGB(XGetPixel(xi, x, y), r + lineoffset+x, g + lineoffset+x, b + lineoffset+x); } } XDestroyImage(xi); } }
void iupdrvImageGetData(void* handle, unsigned char* imgdata) { Pixmap pixmap = (Pixmap)handle; int w, h, y, x, bpp; XImage *xi; if (!iupdrvImageGetInfo(handle, &w, &h, &bpp)) return; if (bpp == 8) return; xi = XGetImage(iupmot_display, pixmap, 0, 0, w, h, ULONG_MAX, ZPixmap); if (xi) { /* planes are packed and top-bottom in this imgdata */ int planesize = w*h; unsigned char *line_data; for (y = 0; y<h; y++) { line_data = imgdata + y * planesize; for (x = 0; x<w; x++) { iupmotColorGetRGB(XGetPixel(xi, x, y), line_data + x, line_data + x + 1, line_data + x + 2); } } XDestroyImage(xi); } }
char* iupmotGetBgColorAttrib(Ihandle* ih) { unsigned char r, g, b; Pixel color; XtVaGetValues(ih->handle, XmNbackground, &color, NULL); iupmotColorGetRGB(color, &r, &g, &b); return iupStrReturnStrf("%d %d %d", (int)r, (int)g, (int)b); }
static char* motToggleGetSelectColorAttrib(Ihandle* ih) { unsigned char r, g, b; Pixel color; XtVaGetValues(ih->handle, XmNselectColor, &color, NULL); iupmotColorGetRGB(color, &r, &g, &b); return iupStrReturnStrf("%d %d %d", (int)r, (int)g, (int)b); }
char* iupmotGetBgColorAttrib(Ihandle* ih) { unsigned char r, g, b; Pixel color; char* str = iupStrGetMemory(20); XtVaGetValues(ih->handle, XmNbackground, &color, NULL); iupmotColorGetRGB(color, &r, &g, &b); sprintf(str, "%d %d %d", (int)r, (int)g, (int)b); return str; }
static char* motToggleGetSelectColorAttrib(Ihandle* ih) { unsigned char r, g, b; Pixel color; char* str = iupStrGetMemory(20); XtVaGetValues(ih->handle, XmNselectColor, &color, NULL); iupmotColorGetRGB(color, &r, &g, &b); sprintf(str, "%d %d %d", (int)r, (int)g, (int)b); return str; }