From d577d991b97ae2b5ee1af23641bcffc3f83af5b2 Mon Sep 17 00:00:00 2001 From: Pixel Date: Wed, 4 Nov 2009 11:56:41 -0800 Subject: Initial import. Contains the im, cd and iup librairies, and a "working" Makefile for them under linux. --- iup/src/mot/iupmot_image.c | 397 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 397 insertions(+) create mode 100755 iup/src/mot/iupmot_image.c (limited to 'iup/src/mot/iupmot_image.c') diff --git a/iup/src/mot/iupmot_image.c b/iup/src/mot/iupmot_image.c new file mode 100755 index 0000000..b0078d5 --- /dev/null +++ b/iup/src/mot/iupmot_image.c @@ -0,0 +1,397 @@ +/** \file + * \brief Image Resource. + * + * See Copyright Notice in "iup.h" + */ + +#include + +#include +#include +#include +#include + +#include "iup.h" + +#include "iup_object.h" +#include "iup_attrib.h" +#include "iup_str.h" +#include "iup_image.h" +#include "iup_drvinfo.h" + +#include "iupmot_drv.h" +#include "iupmot_color.h" + + +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; ycurrentwidth, + height = ih->currentheight; + unsigned char *imgdata = (unsigned char*)iupAttribGetStr(ih, "WID"); + Pixmap pixmap; + unsigned char bg_r=0, bg_g=0, bg_b=0; + GC gc; + Pixel color2pixel[256]; + + bpp = iupAttribGetInt(ih, "BPP"); + + iupStrToRGB(bgcolor, &bg_r, &bg_g, &bg_b); + + if (bpp == 8) + { + int i, colors_count = 0; + iupColor colors[256]; + + iupImageInitColorTable(ih, colors, &colors_count); + + for (i=0;icurrentwidth, + height = ih->currentheight, + line_size = (width+7)/8, + size_bytes = line_size*height; + unsigned char *imgdata = (unsigned char*)iupAttribGetStr(ih, "WID"); + char *sbits, *mbits, *sb, *mb; + Pixmap source, mask; + XColor fg, bg; + unsigned char r, g, b; + Cursor cursor; + + bpp = iupAttribGetInt(ih, "BPP"); + if (bpp > 8) + return NULL; + + sbits = (char*)malloc(2*size_bytes); + if (!sbits) return NULL; + memset(sbits, 0, 2*size_bytes); + mbits = sbits + size_bytes; + + sb = sbits; + mb = mbits; + for (y=0; ycurrentwidth, + height = ih->currentheight, + line_size = (width+7)/8, + size_bytes = line_size*height; + unsigned char *imgdata = (unsigned char*)iupAttribGetStr(ih, "WID"); + char *bits, *sb; + Pixmap mask; + unsigned char colors[256]; + + bpp = iupAttribGetInt(ih, "BPP"); + if (bpp > 8) + return NULL; + + bits = (char*)malloc(size_bytes); + if (!bits) return NULL; + memset(bits, 0, size_bytes); + + iupImageInitNonBgColors(ih, colors); + + sb = bits; + for (y=0; y