diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2024-02-19 14:37:23 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2024-02-19 14:37:23 -0800 |
commit | b30fd0918f8d99aa718ede3da30f9d29f87063e1 (patch) | |
tree | fc20a7c915ad5dfe3ea8fbb87dd5fd71eccd1956 | |
parent | 0224b43072c5ce42ec4f3280e6f6022a2e5380c6 (diff) |
Remove ancient port to 16-bit Windows without X11 libraries
Removes all the "FOR_MSW" code added back in 1994, which hasn't been
buildable in the automake builds.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | doc/Makefile.am | 3 | ||||
-rw-r--r-- | doc/README.MSW | 127 | ||||
-rw-r--r-- | include/X11/xpm.h | 33 | ||||
-rw-r--r-- | src/CrBufFrI.c | 4 | ||||
-rw-r--r-- | src/CrDatFrI.c | 4 | ||||
-rw-r--r-- | src/Makefile.am | 3 | ||||
-rw-r--r-- | src/RdFToBuf.c | 9 | ||||
-rw-r--r-- | src/RdFToI.c | 4 | ||||
-rw-r--r-- | src/WrFFrI.c | 6 | ||||
-rw-r--r-- | src/XpmI.h | 22 | ||||
-rw-r--r-- | src/create.c | 161 | ||||
-rw-r--r-- | src/parse.c | 16 | ||||
-rw-r--r-- | src/rgb.c | 138 | ||||
-rw-r--r-- | src/rgbtab.h | 292 | ||||
-rw-r--r-- | src/scan.c | 69 | ||||
-rw-r--r-- | src/simx.c | 293 | ||||
-rw-r--r-- | src/simx.h | 154 |
17 files changed, 12 insertions, 1326 deletions
diff --git a/doc/Makefile.am b/doc/Makefile.am index 4e8e8f9..b701210 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,5 +1,4 @@ EXTRA_DIST = \ xpm.PS.gz \ FAQ.html \ - README.html \ - README.MSW + README.html diff --git a/doc/README.MSW b/doc/README.MSW deleted file mode 100644 index d7cfaf6..0000000 --- a/doc/README.MSW +++ /dev/null @@ -1,127 +0,0 @@ - -README.MSW hedu@cul-ipn.uni-kiel.de 5/94 - - The XPM library for MS-Windows - -Motivated by the wxWindows library, which is a (freely available) toolkit -for developing multi-platform, graphical applications from the same body -of C++ code, I wanted to have XPM pixmaps for MS-windows. Instead of rewriting -a XPM-parser I managed to port the XPM-library-code to MS-windows. -Thanks to Anaud Le Hors this became a part of the official XPM-library. - -Until now it's only used together with wxWindows. And even there it's more -a kind of beta. But it should be possible to run it as a simple libxpm.a -without wxWindows. - -The key is a transformation of some X types plus some basic X functions. -There is not yet a special MSW-API, so you should know the X types used. - -The following is done in simx.h: - -typedef HDC Display; -typedef COLORREF Pixel; - -typedef struct { - Pixel pixel; - BYTE red, green, blue; -} XColor; - -typedef struct { - HBITMAP bitmap; - unsigned int width; - unsigned int height; - unsigned int depth; -} XImage; - -With these defines and the according functions from simx.c you can call -XPM-functions the way it's done under X windows. It can look like this: - - ErrorStatus=XpmCreateImageFromData(&dc, data, - &ximage,(XImage **)NULL, &xpmAttr); - ms_bitmap = ximage->bitmap; - // releases the malloc,but do not destroy the bitmap - XImageFree(ximage); - -Supported functions are the Xpm*Image* but not the Xpm*Pixmap*. - -DRAWBACKS: -The main drawback is the missing support for Colormaps! There was nothing for -it in wxWindows, so I did not know how to deal with Colormaps. - -The size of the pixmaps is bounded by malloc() (width*height*2 < 64K). - -Close colors do not look that close. But that seems to be the window system. - -Neither a special API for MSW nor a special MSW documentation other than this. -(I can only point you to wxxpm as an example , see below.) - -INSTALLATION: -There is not yet a makefile with it. Simply take all the *.c files -into your project except the files related to Pixmap operations: *P*.c. -!!!You MUST set FOR_MSW on the preprocessor options!!! -(You might uncomment NEED_STRCASECMP in xpm.h if it's in your lib) -This should compile into libxpm.a. Good luck... - -FTP: -wxWindows is currently available from the Artificial Intelligence -Applications Institute (University of Edinburgh) by anonymous FTP. - skye.aiai.ed.ac.uk pub/wxwin/ -or read http://burray.aiai.ed.ac.uk/aiai/aiai.html - -wxxpm, XPM support for wxWindows, the latest version is available at - yoda.cul-ipn.uni-kiel.de pub/wxxpm/ - and maybe in the contrib or tools of wxWindows - -Please contact me if you have suggestions, comments or problems! - -================================================================ -Some fixes and comments by Jan Wielemaker (jan@swi.psy.uva.nl), -Oct 24, 1996: - - * Please try not to disturb me on this, XPM is not my - piece of cake. - - * Hermann Dunkel has apparently moved in virtual space. - -Changes: - - * I've used the xpm package under NT 4.0 and MSVC++ 4.2. - - * I've made a big performance improvement in - ParseAndPutPixels(), fixed creation of the mask in - SetColor() in create.c. I looked into XCreateImage() - in simx.c, but commented out my improvement for reasons - you'll find there. If you know what is going on, statement - (1) does not apply to you. - -Comments on installation: - - * Donot include the to/from pixmap files into the project. - These are the ones containing a capital P somewhere in their - name. You can also first include all, and then remove all - the files you get errors on :-) - - * The DC that is requested should be a valid memory DC, thus - CreateCompatibleDC(NULL) provides a good generic one, but - GetDC(NULL) doesn't! This costed me some time. - - * The real difficulty is using the mask, mostly due to the - bad documentation. If 95 or NT is your target, use: - - MaskBlt(context.hdc, // Destination DC - x, y, w, h, // Destination area - mhdc, // Memory DC with the image selected - sx, sy, // Source X,Y - msk, // HBITMAP of the mask - sx, sy, // Mask X,Y - MAKEROP4(SRCPAINT, SRCCOPY)); // The magic op code. -================================================================ - - --- - ////|\\\\ \\\\\\ Hermann Dunkel - O O ////// IPN Uni Kiel, Germany - | \\\\\\ Tel: +49 431 / 880 3144 - \___/ ////// E-mail: hedu@cul-ipn.uni-kiel.de - \_/ \\\\\\ X.400 : c=de;a=d400;p=uni-kiel;ou=nw-didaktik;s=dunkel - diff --git a/include/X11/xpm.h b/include/X11/xpm.h index 32eb3b8..37d3b08 100644 --- a/include/X11/xpm.h +++ b/include/X11/xpm.h @@ -32,11 +32,6 @@ * Developed by Arnaud Le Hors * \*****************************************************************************/ -/* - * The code related to FOR_MSW has been added by - * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94 - */ - #ifndef XPM_h #define XPM_h @@ -59,16 +54,9 @@ #ifndef XPM_NUMBERS -#ifdef FOR_MSW -# define SYSV /* uses memcpy string.h etc. */ -# include <malloc.h> -# include "simx.h" /* defines some X stuff using MSW types */ -#define NEED_STRCASECMP /* at least for MSVC++ */ -#else /* FOR_MSW */ # include <X11/Xfuncproto.h> # include <X11/Xlib.h> # include <X11/Xutil.h> -#endif /* FOR_MSW */ /* let's define Pixel if it is not done yet */ #if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED) @@ -247,12 +235,7 @@ typedef struct { #define XpmReturnComments XpmComments /* XpmAttributes mask_pixel value when there is no mask */ -#ifndef FOR_MSW #define XpmUndefPixel 0x80000000 -#else -/* int is only 16 bit for MSW */ -#define XpmUndefPixel 0x8000 -#endif /* * color keys for visual type, they must fit along with the number key of @@ -282,9 +265,6 @@ typedef struct { _XFUNCPROTOBEGIN -/* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */ - -#ifndef FOR_MSW FUNC(XpmCreatePixmapFromData, int, (Display *display, Drawable d, char **data, @@ -310,7 +290,6 @@ _XFUNCPROTOBEGIN Pixmap pixmap, Pixmap shapemask, XpmAttributes *attributes)); -#endif FUNC(XpmCreateImageFromData, int, (Display *display, char **data, @@ -341,7 +320,7 @@ _XFUNCPROTOBEGIN XImage **image_return, XImage **shapemask_return, XpmAttributes *attributes)); -#ifndef FOR_MSW + FUNC(XpmCreatePixmapFromBuffer, int, (Display *display, Drawable d, char *buffer, @@ -360,7 +339,7 @@ _XFUNCPROTOBEGIN Pixmap pixmap, Pixmap shapemask, XpmAttributes *attributes)); -#endif + FUNC(XpmReadFileToBuffer, int, (const char *filename, char **buffer_return)); FUNC(XpmWriteFileFromBuffer, int, (const char *filename, char *buffer)); @@ -385,14 +364,14 @@ _XFUNCPROTOBEGIN FUNC(XpmWriteFileFromXpmImage, int, (const char *filename, XpmImage *image, XpmInfo *info)); -#ifndef FOR_MSW + FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display, Drawable d, XpmImage *image, Pixmap *pixmap_return, Pixmap *shapemask_return, XpmAttributes *attributes)); -#endif + FUNC(XpmCreateImageFromXpmImage, int, (Display *display, XpmImage *image, XImage **image_return, @@ -404,13 +383,13 @@ _XFUNCPROTOBEGIN XImage *shapeimage, XpmImage *xpmimage, XpmAttributes *attributes)); -#ifndef FOR_MSW + FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display, Pixmap pixmap, Pixmap shapemask, XpmImage *xpmimage, XpmAttributes *attributes)); -#endif + FUNC(XpmCreateDataFromXpmImage, int, (char ***data_return, XpmImage *image, XpmInfo *info)); diff --git a/src/CrBufFrI.c b/src/CrBufFrI.c index e2040db..398c645 100644 --- a/src/CrBufFrI.c +++ b/src/CrBufFrI.c @@ -39,10 +39,6 @@ #endif #include "XpmI.h" -#ifdef FOR_MSW -#define snprintf _snprintf -#endif - LFUNC(WriteColors, int, (char **dataptr, unsigned int *data_size, unsigned int *used_size, XpmColor *colors, unsigned int ncolors, unsigned int cpp)); diff --git a/src/CrDatFrI.c b/src/CrDatFrI.c index adb4786..8a77e1d 100644 --- a/src/CrDatFrI.c +++ b/src/CrDatFrI.c @@ -39,10 +39,6 @@ #endif #include "XpmI.h" -#ifdef FOR_MSW -#define snprintf _snprintf -#endif - LFUNC(CreateColors, int, (char **dataptr, unsigned int *data_size, XpmColor *colors, unsigned int ncolors, unsigned int cpp)); diff --git a/src/Makefile.am b/src/Makefile.am index acca24b..bc97bf6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -37,7 +37,4 @@ libXpm_la_SOURCES = \ misc.c \ parse.c \ rgb.c \ - rgbtab.h \ scan.c - -EXTRA_DIST = simx.c simx.h diff --git a/src/RdFToBuf.c b/src/RdFToBuf.c index 10e9d22..8f7c31a 100644 --- a/src/RdFToBuf.c +++ b/src/RdFToBuf.c @@ -32,11 +32,6 @@ * Developed by Arnaud Le Hors * \*****************************************************************************/ -/* - * The code related to FOR_MSW has been added by - * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94 - */ - /* October 2004, source code review by Thomas Biege <thomas@suse.de> */ #ifdef HAVE_CONFIG_H @@ -44,11 +39,11 @@ #endif #include "XpmI.h" #include <sys/stat.h> -#if !defined(FOR_MSW) && !defined(WIN32) +#ifndef WIN32 #include <unistd.h> #endif #include <fcntl.h> -#if defined(FOR_MSW) || defined(WIN32) +#ifdef WIN32 #include <io.h> #define stat _stat #define fstat _fstat diff --git a/src/RdFToI.c b/src/RdFToI.c index 0ce78cd..4deb44b 100644 --- a/src/RdFToI.c +++ b/src/RdFToI.c @@ -44,10 +44,6 @@ #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> -#else -#ifdef FOR_MSW -#include <fcntl.h> -#endif #endif LFUNC(OpenReadFile, int, (const char *filename, xpmData *mdata)); diff --git a/src/WrFFrI.c b/src/WrFFrI.c index f48a93b..7a9177b 100644 --- a/src/WrFFrI.c +++ b/src/WrFFrI.c @@ -46,12 +46,6 @@ #include "fcntl.h" -#ifdef FOR_MSW -#define O_WRONLY _O_WRONLY -#define O_CREAT _O_CREAT -#define O_TRUNC _O_TRUNC -#endif - /* MS Windows define a function called WriteFile @#%#&!!! */ LFUNC(xpmWriteFile, int, (FILE *file, XpmImage *image, const char *name, XpmInfo *info)); @@ -34,11 +34,6 @@ * Developed by Arnaud Le Hors * \*****************************************************************************/ -/* - * The code related to FOR_MSW has been added by - * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94 - */ - #ifndef XPMI_h #define XPMI_h @@ -53,13 +48,9 @@ #include <stdlib.h> #include <limits.h> -#ifdef FOR_MSW -#include "simx.h" -#else #include <X11/Xos.h> #include <X11/Xfuncs.h> #include <X11/Xmd.h> -#endif #ifdef VMS #include <unixio.h> @@ -75,17 +66,9 @@ */ #define XpmFree(ptr) free(ptr) -#ifndef FOR_MSW #define XpmMalloc(size) malloc((size)) #define XpmRealloc(ptr, size) realloc((ptr), (size)) #define XpmCalloc(nelem, elsize) calloc((nelem), (elsize)) -#else -/* checks for mallocs bigger than 64K */ -#define XpmMalloc(size) boundCheckingMalloc((long)(size))/* in simx.[ch] */ -#define XpmRealloc(ptr, size) boundCheckingRealloc((ptr),(long)(size)) -#define XpmCalloc(nelem, elsize) \ - boundCheckingCalloc((long)(nelem),(long) (elsize)) -#endif #include <stdint.h> /* For SIZE_MAX */ #include <limits.h> @@ -188,7 +171,6 @@ HFUNC(xpmSetInfo, void, (XpmInfo *info, XpmAttributes *attributes)); HFUNC(xpmSetAttributes, void, (XpmAttributes *attributes, XpmImage *image, XpmInfo *info)); -#ifndef FOR_MSW HFUNC(xpmCreatePixmapFromImage, int, (Display *display, Drawable d, XImage *ximage, Pixmap *pixmap_return)); @@ -196,7 +178,6 @@ HFUNC(xpmCreateImageFromPixmap, void, (Display *display, Pixmap pixmap, XImage **ximage_return, unsigned int *width, unsigned int *height)); -#endif /* structures and functions related to hastable code */ @@ -259,9 +240,6 @@ HFUNC(xpmReadRgbNames, int, (const char *rgb_fname, xpmRgbName *rgbn)); HFUNC(xpmGetRgbName, char *, (xpmRgbName *rgbn, int rgbn_max, int red, int green, int blue)); HFUNC(xpmFreeRgbNames, void, (xpmRgbName *rgbn, int rgbn_max)); -#ifdef FOR_MSW -HFUNC(xpmGetRGBfromName,int, (char *name, int *r, int *g, int *b)); -#endif HFUNC(xpm_xynormalizeimagebits, void, (register unsigned char *bp, register XImage *img)); diff --git a/src/create.c b/src/create.c index 5dd0d29..42a5312 100644 --- a/src/create.c +++ b/src/create.c @@ -33,11 +33,6 @@ * Developed by Arnaud Le Hors * \*****************************************************************************/ -/* - * The code related to FOR_MSW has been added by - * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94 - */ - /* October 2004, source code review by Thomas Biege <thomas@suse.de> */ #ifdef HAVE_CONFIG_H @@ -53,16 +48,12 @@ LFUNC(AllocColor, int, (Display *display, Colormap colormap, LFUNC(FreeColors, int, (Display *display, Colormap colormap, Pixel *pixels, int n, void *closure)); -#ifndef FOR_MSW LFUNC(SetCloseColor, int, (Display *display, Colormap colormap, Visual *visual, XColor *col, Pixel *image_pixel, Pixel *mask_pixel, Pixel *alloc_pixels, unsigned int *nalloc_pixels, XpmAttributes *attributes, XColor *cols, int ncols, XpmAllocColorFunc allocColor, void *closure)); -#else -/* let the window system take care of close colors */ -#endif LFUNC(SetColor, int, (Display *display, Colormap colormap, Visual *visual, char *colorname, unsigned int color_index, @@ -84,23 +75,13 @@ LFUNC(CreateColors, int, (Display *display, XpmAttributes *attributes, Pixel *alloc_pixels, unsigned int *nalloc_pixels, Pixel *used_pixels, unsigned int *nused_pixels)); -#ifndef FOR_MSW LFUNC(ParseAndPutPixels, int, (xpmData *data, unsigned int width, unsigned int height, unsigned int ncolors, unsigned int cpp, XpmColor *colorTable, xpmHashTable *hashtable, XImage *image, Pixel *image_pixels, XImage *mask, Pixel *mask_pixels)); -#else /* FOR_MSW */ -LFUNC(ParseAndPutPixels, int, (Display *dc, xpmData *data, unsigned int width, - unsigned int height, unsigned int ncolors, - unsigned int cpp, XpmColor *colorTable, - xpmHashTable *hashtable, - XImage *image, Pixel *image_pixels, - XImage *mask, Pixel *mask_pixels)); -#endif -#ifndef FOR_MSW /* XImage pixel routines */ LFUNC(PutImagePixels, void, (XImage *image, unsigned int width, unsigned int height, unsigned int *pixelindex, @@ -135,13 +116,6 @@ LFUNC(PutPixel8, int, (XImage *ximage, int x, int y, unsigned long pixel)); LFUNC(PutPixel1MSB, int, (XImage *ximage, int x, int y, unsigned long pixel)); LFUNC(PutPixel1LSB, int, (XImage *ximage, int x, int y, unsigned long pixel)); -#else /* FOR_MSW */ -/* FOR_MSW pixel routine */ -LFUNC(MSWPutImagePixels, void, (Display *dc, XImage *image, - unsigned int width, unsigned int height, - unsigned int *pixelindex, Pixel *pixels)); -#endif /* FOR_MSW */ - #ifdef NEED_STRCASECMP FUNC(xpmstrcasecmp, int, (char *s1, char *s2)); @@ -175,7 +149,6 @@ xpmstrcasecmp( static int xpmVisualType(Visual *visual) { -#ifndef FOR_MSW switch (visual->class) { case StaticGray: case GrayScale: @@ -190,10 +163,6 @@ xpmVisualType(Visual *visual) default: return (XPM_COLOR); } -#else - /* there should be a similar switch for MSW */ - return (XPM_COLOR); -#endif } @@ -233,7 +202,6 @@ AllocColor( } -#ifndef FOR_MSW /* * set a close color in case the exact one can't be set * return 0 if success, 1 otherwise. @@ -413,10 +381,6 @@ SetCloseColor( || attributes->green_closeness != 0 \ || attributes->blue_closeness != 0))) -#else - /* FOR_MSW part */ - /* nothing to do here, the window system does it */ -#endif /* * set the color pixel related to the given colorname, @@ -452,7 +416,6 @@ SetColor( return (1); if (status == 0) { -#ifndef FOR_MSW if (USE_CLOSECOLOR) return (SetCloseColor(display, colormap, visual, &xcolor, image_pixel, mask_pixel, @@ -460,24 +423,15 @@ SetColor( attributes, cols, ncols, allocColor, closure)); else -#endif /* ndef FOR_MSW */ return (1); } else alloc_pixels[(*nalloc_pixels)++] = xcolor.pixel; *image_pixel = xcolor.pixel; -#ifndef FOR_MSW *mask_pixel = 1; -#else - *mask_pixel = RGB(0,0,0); -#endif used_pixels[(*nused_pixels)++] = xcolor.pixel; } else { *image_pixel = 0; -#ifndef FOR_MSW *mask_pixel = 0; -#else - *mask_pixel = RGB(255,255,255); -#endif /* store the color table index */ *mask_pixel_index = color_index; } @@ -552,7 +506,6 @@ CreateColors( else closure = NULL; -#ifndef FOR_MSW if (USE_CLOSECOLOR) { /* originally from SetCloseColor */ #if 0 @@ -579,7 +532,6 @@ CreateColors( } #endif } -#endif /* ndef FOR_MSW */ switch (key) { case XPM_MONO: @@ -839,7 +791,6 @@ XpmCreateImageFromXpmImage( if (ErrorStatus != XpmSuccess) RETURN(ErrorStatus); -#ifndef FOR_MSW /* * set the ximage data using optimized functions for ZPixmap */ @@ -860,10 +811,6 @@ XpmCreateImageFromXpmImage( else PutImagePixels(ximage, image->width, image->height, image->data, image_pixels); -#else /* FOR_MSW */ - MSWPutImagePixels(display, ximage, image->width, image->height, - image->data, image_pixels); -#endif } /* create the shape mask image */ if (mask_pixel_index != XpmUndefPixel && shapeimage_return) { @@ -872,13 +819,8 @@ XpmCreateImageFromXpmImage( if (ErrorStatus != XpmSuccess) RETURN(ErrorStatus); -#ifndef FOR_MSW PutImagePixels1(shapeimage, image->width, image->height, image->data, mask_pixels); -#else /* FOR_MSW */ - MSWPutImagePixels(display, shapeimage, image->width, image->height, - image->data, mask_pixels); -#endif } XpmFree(image_pixels); @@ -960,7 +902,6 @@ CreateXImage( if (!*image_return) return (XpmNoMemory); -#ifndef FOR_MSW if (height != 0 && (*image_return)->bytes_per_line >= INT_MAX / height) { XDestroyImage(*image_return); *image_return = NULL; @@ -985,13 +926,9 @@ CreateXImage( *image_return = NULL; return (XpmNoMemory); } -#else - /* under FOR_MSW XCreateImage has done it all */ -#endif return (XpmSuccess); } -#ifndef FOR_MSW /* * The functions below are written from X11R5 MIT's code (XImUtil.c) * @@ -1673,35 +1610,6 @@ XpmCreatePixmapFromXpmImage( return (ErrorStatus); } -#else /* FOR_MSW part follows */ -static void -MSWPutImagePixels( - Display *dc, - XImage *image, - unsigned int width, - unsigned int height, - unsigned int *pixelindex, - Pixel *pixels) -{ - unsigned int *data = pixelindex; - unsigned int x, y; - HBITMAP obm; - - obm = SelectObject(*dc, image->bitmap); - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++) { - SetPixel(*dc, x, y, pixels[*(data++)]); /* data is [x+y*width] */ - } - } - SelectObject(*dc, obm); -} - -#endif /* FOR_MSW */ - - - -#ifndef FOR_MSW - static int PutPixel1( register XImage *ximage, @@ -1918,7 +1826,6 @@ PutPixel1LSB( return 1; } -#endif /* not FOR_MSW */ /* * This function parses an Xpm file or data and directly create an XImage @@ -2085,7 +1992,6 @@ xpmParseDataAndCreate( if (ErrorStatus != XpmSuccess) RETURN(ErrorStatus); -#ifndef FOR_MSW /* * set the XImage pointer function, to be used with XPutPixel, @@ -2119,7 +2025,6 @@ xpmParseDataAndCreate( ximage->f.put_pixel = PutPixel1; else ximage->f.put_pixel = PutPixel; -#endif /* not FOR_MSW */ } /* create the shape mask image */ @@ -2129,22 +2034,16 @@ xpmParseDataAndCreate( if (ErrorStatus != XpmSuccess) RETURN(ErrorStatus); -#ifndef FOR_MSW if (shapeimage->bitmap_bit_order == MSBFirst) shapeimage->f.put_pixel = PutPixel1MSB; else shapeimage->f.put_pixel = PutPixel1LSB; -#endif } /* * read pixels and put them in the XImage */ - ErrorStatus = ParseAndPutPixels( -#ifdef FOR_MSW - display, -#endif - data, width, height, ncolors, cpp, + ErrorStatus = ParseAndPutPixels(data, width, height, ncolors, cpp, colorTable, &hashtable, ximage, image_pixels, shapeimage, mask_pixels); @@ -2261,9 +2160,6 @@ error: static int ParseAndPutPixels( -#ifdef FOR_MSW - Display *dc, -#endif xpmData *data, unsigned int width, unsigned int height, @@ -2284,18 +2180,7 @@ ParseAndPutPixels( * colors */ { unsigned short colidx[256]; -#ifdef FOR_MSW - HDC shapedc; - HBITMAP obm, sobm; - if ( shapeimage ) { - shapedc = CreateCompatibleDC(*dc); - sobm = SelectObject(shapedc, shapeimage->bitmap); - } else { - shapedc = NULL; - } - obm = SelectObject(*dc, image->bitmap); -#endif if (ncolors > 256) return (XpmFileInvalid); @@ -2309,28 +2194,14 @@ ParseAndPutPixels( int c = xpmGetC(data); if (c > 0 && c < 256 && colidx[c] != 0) { -#ifndef FOR_MSW XPutPixel(image, x, y, image_pixels[colidx[c] - 1]); if (shapeimage) XPutPixel(shapeimage, x, y, shape_pixels[colidx[c] - 1]); -#else - SetPixel(*dc, x, y, image_pixels[colidx[c] - 1]); - if (shapedc) { - SetPixel(shapedc, x, y, shape_pixels[colidx[c] - 1]); - } -#endif } else return (XpmFileInvalid); } } -#ifdef FOR_MSW - if ( shapedc ) { - SelectObject(shapedc, sobm); - DeleteDC(shapedc); - } - SelectObject(*dc, obm); -#endif } break; @@ -2368,21 +2239,11 @@ if (cidx[f]) XpmFree(cidx[f]);} while(0) int cc2 = xpmGetC(data); if (cc2 > 0 && cc2 < 256 && cidx[cc1] && cidx[cc1][cc2] != 0) { -#ifndef FOR_MSW XPutPixel(image, x, y, image_pixels[cidx[cc1][cc2] - 1]); if (shapeimage) XPutPixel(shapeimage, x, y, shape_pixels[cidx[cc1][cc2] - 1]); -#else - SelectObject(*dc, image->bitmap); - SetPixel(*dc, x, y, image_pixels[cidx[cc1][cc2] - 1]); - if (shapeimage) { - SelectObject(*dc, shapeimage->bitmap); - SetPixel(*dc, x, y, - shape_pixels[cidx[cc1][cc2] - 1]); - } -#endif } else { FREE_CIDX; return (XpmFileInvalid); @@ -2418,22 +2279,11 @@ if (cidx[f]) XpmFree(cidx[f]);} while(0) slot = xpmHashSlot(hashtable, buf); if (!*slot) /* no color matches */ return (XpmFileInvalid); -#ifndef FOR_MSW XPutPixel(image, x, y, image_pixels[HashColorIndex(slot)]); if (shapeimage) XPutPixel(shapeimage, x, y, shape_pixels[HashColorIndex(slot)]); -#else - SelectObject(*dc, image->bitmap); - SetPixel(*dc, x, y, - image_pixels[HashColorIndex(slot)]); - if (shapeimage) { - SelectObject(*dc, shapeimage->bitmap); - SetPixel(*dc, x, y, - shape_pixels[HashColorIndex(slot)]); - } -#endif } } } else { @@ -2447,18 +2297,9 @@ if (cidx[f]) XpmFree(cidx[f]);} while(0) break; if (a == ncolors) /* no color matches */ return (XpmFileInvalid); -#ifndef FOR_MSW XPutPixel(image, x, y, image_pixels[a]); if (shapeimage) XPutPixel(shapeimage, x, y, shape_pixels[a]); -#else - SelectObject(*dc, image->bitmap); - SetPixel(*dc, x, y, image_pixels[a]); - if (shapeimage) { - SelectObject(*dc, shapeimage->bitmap); - SetPixel(*dc, x, y, shape_pixels[a]); - } -#endif } } } diff --git a/src/parse.c b/src/parse.c index ab65f50..cd923f9 100644 --- a/src/parse.c +++ b/src/parse.c @@ -33,11 +33,6 @@ * Developed by Arnaud Le Hors * \*****************************************************************************/ -/* - * The code related to FOR_MSW has been added by - * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94 - */ - /* October 2004, source code review by Thomas Biege <thomas@suse.de> */ #ifdef HAVE_CONFIG_H @@ -419,17 +414,8 @@ ParsePixels( if ((height > 0 && width >= UINT_MAX / height) || width * height >= UINT_MAX / sizeof(unsigned int)) return XpmNoMemory; -#ifndef FOR_MSW - iptr2 = (unsigned int *) XpmMalloc(sizeof(unsigned int) * width * height); -#else - /* - * special treatment to trick DOS malloc(size_t) where size_t is 16 bit!! - * XpmMalloc is defined to longMalloc(long) and checks the 16 bit boundary - */ - iptr2 = (unsigned int *) - XpmMalloc((long) sizeof(unsigned int) * (long) width * (long) height); -#endif + iptr2 = (unsigned int *) XpmMalloc(sizeof(unsigned int) * width * height); if (!iptr2) return (XpmNoMemory); @@ -33,11 +33,6 @@ \*****************************************************************************/ /* - * The code related to FOR_MSW has been added by - * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94 - */ - -/* * Part of this code has been taken from the ppmtoxpm.c file written by Mark * W. Snitily but has been modified for my special need */ @@ -48,8 +43,6 @@ #include "XpmI.h" #include <ctype.h> -#ifndef FOR_MSW /* normal part first, MSW part at - * the end, (huge ifdef!) */ /* * Read a rgb text file. It stores the rgb values (0->65535) * and the rgb mnemonics (malloc'ed) into the "rgbn" array. Returns the @@ -154,134 +147,3 @@ xpmFreeRgbNames( for (i = 0, rgb = rgbn; i < rgbn_max; i++, rgb++) XpmFree(rgb->name); } - -#else /* here comes the MSW part, the - * second part of the huge ifdef */ - -#include "rgbtab.h" /* hard coded rgb.txt table */ - -int -xpmReadRgbNames( - const char *rgb_fname, - xpmRgbName rgbn[]) -{ - /* - * check for consistency??? - * table has to be sorted for calls on strcasecmp - */ - return (numTheRGBRecords); -} - -/* - * MSW rgb values are made from 3 BYTEs, this is different from X XColor.red, - * which has something like #0303 for one color - */ -char * -xpmGetRgbName( - xpmRgbName rgbn[], /* rgb mnemonics from rgb text file - * not used */ - int rgbn_max, /* not used */ - int red, /* rgb values */ - int green, - int blue) - -{ - int i; - unsigned long rgbVal; - - i = 0; - while (i < numTheRGBRecords) { - rgbVal = theRGBRecords[i].rgb; - if (GetRValue(rgbVal) == red && - GetGValue(rgbVal) == green && - GetBValue(rgbVal) == blue) - return (theRGBRecords[i].name); - i++; - } - return (NULL); -} - -/* used in XParseColor in simx.c */ -int -xpmGetRGBfromName( - char *inname, - int *r, - int *g, - int *b) -{ - int left, right, middle; - int cmp; - unsigned long rgbVal; - char *name; - char *grey, *p; - - name = xpmstrdup(inname); - - /* - * the table in rgbtab.c has no names with spaces, and no grey, but a - * lot of gray - */ - /* so first extract ' ' */ - while (p = strchr(name, ' ')) { - while (*(p)) { /* till eof of string */ - *p = *(p + 1); /* copy to the left */ - p++; - } - } - /* fold to lower case */ - p = name; - while (*p) { - *p = tolower(*p); - p++; - } - - /* - * substitute Grey with Gray, else rgbtab.h would have more than 100 - * 'duplicate' entries - */ - if (grey = strstr(name, "grey")) - grey[2] = 'a'; - - /* binary search */ - left = 0; - right = numTheRGBRecords - 1; - do { - middle = (left + right) / 2; - cmp = xpmstrcasecmp(name, theRGBRecords[middle].name); - if (cmp == 0) { - rgbVal = theRGBRecords[middle].rgb; - *r = GetRValue(rgbVal); - *g = GetGValue(rgbVal); - *b = GetBValue(rgbVal); - free(name); - return (1); - } else if (cmp < 0) { - right = middle - 1; - } else { /* > 0 */ - left = middle + 1; - } - } while (left <= right); - - /* - * I don't like to run in a ColorInvalid error and to see no pixmap at - * all, so simply return a red pixel. Should be wrapped in an #ifdef - * HeDu - */ - - *r = 255; - *g = 0; - *b = 0; /* red error pixel */ - - free(name); - return (1); -} - -void -xpmFreeRgbNames( - xpmRgbName rgbn[], - int rgbn_max) -{ - /* nothing to do */ -} - -#endif /* MSW part */ diff --git a/src/rgbtab.h b/src/rgbtab.h deleted file mode 100644 index 6d30f15..0000000 --- a/src/rgbtab.h +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright (C) 1989-95 GROUPE BULL - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of GROUPE BULL shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from GROUPE BULL. - */ - -/*****************************************************************************\ -* rgbtab.h * -* * -* A hard coded rgb.txt. To keep it short I removed all colornames with * -* trailing numbers, Blue3 etc, except the GrayXX. Sorry Grey-lovers I prefer * -* Gray ;-). But Grey is recognized on lookups, only on save Gray will be * -* used, maybe you want to do some substitute there too. * -* * -* To save memory the RGBs are coded in one long value, as done by the RGB * -* macro. * -* * -* Developed by HeDu 3/94 (hedu@cul-ipn.uni-kiel.de) * -\*****************************************************************************/ - - -typedef struct { - char *name; - COLORREF rgb; /* it's unsigned long */ -} rgbRecord; - -/* -#define myRGB(r,g,b) \ - ((unsigned long)r<<16|(unsigned long)g<<8|(unsigned long)b) -*/ -#define myRGB(r,g,b) RGB(r,g,b) /* MSW has this macro */ - - -static rgbRecord theRGBRecords[] = -{ - {"AliceBlue", myRGB(240, 248, 255)}, - {"AntiqueWhite", myRGB(250, 235, 215)}, - {"Aquamarine", myRGB(50, 191, 193)}, - {"Azure", myRGB(240, 255, 255)}, - {"Beige", myRGB(245, 245, 220)}, - {"Bisque", myRGB(255, 228, 196)}, - {"Black", myRGB(0, 0, 0)}, - {"BlanchedAlmond", myRGB(255, 235, 205)}, - {"Blue", myRGB(0, 0, 255)}, - {"BlueViolet", myRGB(138, 43, 226)}, - {"Brown", myRGB(165, 42, 42)}, - {"burlywood", myRGB(222, 184, 135)}, - {"CadetBlue", myRGB(95, 146, 158)}, - {"chartreuse", myRGB(127, 255, 0)}, - {"chocolate", myRGB(210, 105, 30)}, - {"Coral", myRGB(255, 114, 86)}, - {"CornflowerBlue", myRGB(34, 34, 152)}, - {"cornsilk", myRGB(255, 248, 220)}, - {"Cyan", myRGB(0, 255, 255)}, - {"DarkGoldenrod", myRGB(184, 134, 11)}, - {"DarkGreen", myRGB(0, 86, 45)}, - {"DarkKhaki", myRGB(189, 183, 107)}, - {"DarkOliveGreen", myRGB(85, 86, 47)}, - {"DarkOrange", myRGB(255, 140, 0)}, - {"DarkOrchid", myRGB(139, 32, 139)}, - {"DarkSalmon", myRGB(233, 150, 122)}, - {"DarkSeaGreen", myRGB(143, 188, 143)}, - {"DarkSlateBlue", myRGB(56, 75, 102)}, - {"DarkSlateGray", myRGB(47, 79, 79)}, - {"DarkTurquoise", myRGB(0, 166, 166)}, - {"DarkViolet", myRGB(148, 0, 211)}, - {"DeepPink", myRGB(255, 20, 147)}, - {"DeepSkyBlue", myRGB(0, 191, 255)}, - {"DimGray", myRGB(84, 84, 84)}, - {"DodgerBlue", myRGB(30, 144, 255)}, - {"Firebrick", myRGB(142, 35, 35)}, - {"FloralWhite", myRGB(255, 250, 240)}, - {"ForestGreen", myRGB(80, 159, 105)}, - {"gainsboro", myRGB(220, 220, 220)}, - {"GhostWhite", myRGB(248, 248, 255)}, - {"Gold", myRGB(218, 170, 0)}, - {"Goldenrod", myRGB(239, 223, 132)}, - {"Gray", myRGB(126, 126, 126)}, - {"Gray0", myRGB(0, 0, 0)}, - {"Gray1", myRGB(3, 3, 3)}, - {"Gray10", myRGB(26, 26, 26)}, - {"Gray100", myRGB(255, 255, 255)}, - {"Gray11", myRGB(28, 28, 28)}, - {"Gray12", myRGB(31, 31, 31)}, - {"Gray13", myRGB(33, 33, 33)}, - {"Gray14", myRGB(36, 36, 36)}, - {"Gray15", myRGB(38, 38, 38)}, - {"Gray16", myRGB(41, 41, 41)}, - {"Gray17", myRGB(43, 43, 43)}, - {"Gray18", myRGB(46, 46, 46)}, - {"Gray19", myRGB(48, 48, 48)}, - {"Gray2", myRGB(5, 5, 5)}, - {"Gray20", myRGB(51, 51, 51)}, - {"Gray21", myRGB(54, 54, 54)}, - {"Gray22", myRGB(56, 56, 56)}, - {"Gray23", myRGB(59, 59, 59)}, - {"Gray24", myRGB(61, 61, 61)}, - {"Gray25", myRGB(64, 64, 64)}, - {"Gray26", myRGB(66, 66, 66)}, - {"Gray27", myRGB(69, 69, 69)}, - {"Gray28", myRGB(71, 71, 71)}, - {"Gray29", myRGB(74, 74, 74)}, - {"Gray3", myRGB(8, 8, 8)}, - {"Gray30", myRGB(77, 77, 77)}, - {"Gray31", myRGB(79, 79, 79)}, - {"Gray32", myRGB(82, 82, 82)}, - {"Gray33", myRGB(84, 84, 84)}, - {"Gray34", myRGB(87, 87, 87)}, - {"Gray35", myRGB(89, 89, 89)}, - {"Gray36", myRGB(92, 92, 92)}, - {"Gray37", myRGB(94, 94, 94)}, - {"Gray38", myRGB(97, 97, 97)}, - {"Gray39", myRGB(99, 99, 99)}, - {"Gray4", myRGB(10, 10, 10)}, - {"Gray40", myRGB(102, 102, 102)}, - {"Gray41", myRGB(105, 105, 105)}, - {"Gray42", myRGB(107, 107, 107)}, - {"Gray43", myRGB(110, 110, 110)}, - {"Gray44", myRGB(112, 112, 112)}, - {"Gray45", myRGB(115, 115, 115)}, - {"Gray46", myRGB(117, 117, 117)}, - {"Gray47", myRGB(120, 120, 120)}, - {"Gray48", myRGB(122, 122, 122)}, - {"Gray49", myRGB(125, 125, 125)}, - {"Gray5", myRGB(13, 13, 13)}, - {"Gray50", myRGB(127, 127, 127)}, - {"Gray51", myRGB(130, 130, 130)}, - {"Gray52", myRGB(133, 133, 133)}, - {"Gray53", myRGB(135, 135, 135)}, - {"Gray54", myRGB(138, 138, 138)}, - {"Gray55", myRGB(140, 140, 140)}, - {"Gray56", myRGB(143, 143, 143)}, - {"Gray57", myRGB(145, 145, 145)}, - {"Gray58", myRGB(148, 148, 148)}, - {"Gray59", myRGB(150, 150, 150)}, - {"Gray6", myRGB(15, 15, 15)}, - {"Gray60", myRGB(153, 153, 153)}, - {"Gray61", myRGB(156, 156, 156)}, - {"Gray62", myRGB(158, 158, 158)}, - {"Gray63", myRGB(161, 161, 161)}, - {"Gray64", myRGB(163, 163, 163)}, - {"Gray65", myRGB(166, 166, 166)}, - {"Gray66", myRGB(168, 168, 168)}, - {"Gray67", myRGB(171, 171, 171)}, - {"Gray68", myRGB(173, 173, 173)}, - {"Gray69", myRGB(176, 176, 176)}, - {"Gray7", myRGB(18, 18, 18)}, - {"Gray70", myRGB(179, 179, 179)}, - {"Gray71", myRGB(181, 181, 181)}, - {"Gray72", myRGB(184, 184, 184)}, - {"Gray73", myRGB(186, 186, 186)}, - {"Gray74", myRGB(189, 189, 189)}, - {"Gray75", myRGB(191, 191, 191)}, - {"Gray76", myRGB(194, 194, 194)}, - {"Gray77", myRGB(196, 196, 196)}, - {"Gray78", myRGB(199, 199, 199)}, - {"Gray79", myRGB(201, 201, 201)}, - {"Gray8", myRGB(20, 20, 20)}, - {"Gray80", myRGB(204, 204, 204)}, - {"Gray81", myRGB(207, 207, 207)}, - {"Gray82", myRGB(209, 209, 209)}, - {"Gray83", myRGB(212, 212, 212)}, - {"Gray84", myRGB(214, 214, 214)}, - {"Gray85", myRGB(217, 217, 217)}, - {"Gray86", myRGB(219, 219, 219)}, - {"Gray87", myRGB(222, 222, 222)}, - {"Gray88", myRGB(224, 224, 224)}, - {"Gray89", myRGB(227, 227, 227)}, - {"Gray9", myRGB(23, 23, 23)}, - {"Gray90", myRGB(229, 229, 229)}, - {"Gray91", myRGB(232, 232, 232)}, - {"Gray92", myRGB(235, 235, 235)}, - {"Gray93", myRGB(237, 237, 237)}, - {"Gray94", myRGB(240, 240, 240)}, - {"Gray95", myRGB(242, 242, 242)}, - {"Gray96", myRGB(245, 245, 245)}, - {"Gray97", myRGB(247, 247, 247)}, - {"Gray98", myRGB(250, 250, 250)}, - {"Gray99", myRGB(252, 252, 252)}, - {"Green", myRGB(0, 255, 0)}, - {"GreenYellow", myRGB(173, 255, 47)}, - {"honeydew", myRGB(240, 255, 240)}, - {"HotPink", myRGB(255, 105, 180)}, - {"IndianRed", myRGB(107, 57, 57)}, - {"ivory", myRGB(255, 255, 240)}, - {"Khaki", myRGB(179, 179, 126)}, - {"lavender", myRGB(230, 230, 250)}, - {"LavenderBlush", myRGB(255, 240, 245)}, - {"LawnGreen", myRGB(124, 252, 0)}, - {"LemonChiffon", myRGB(255, 250, 205)}, - {"LightBlue", myRGB(176, 226, 255)}, - {"LightCoral", myRGB(240, 128, 128)}, - {"LightCyan", myRGB(224, 255, 255)}, - {"LightGoldenrod", myRGB(238, 221, 130)}, - {"LightGoldenrodYellow", myRGB(250, 250, 210)}, - {"LightGray", myRGB(168, 168, 168)}, - {"LightPink", myRGB(255, 182, 193)}, - {"LightSalmon", myRGB(255, 160, 122)}, - {"LightSeaGreen", myRGB(32, 178, 170)}, - {"LightSkyBlue", myRGB(135, 206, 250)}, - {"LightSlateBlue", myRGB(132, 112, 255)}, - {"LightSlateGray", myRGB(119, 136, 153)}, - {"LightSteelBlue", myRGB(124, 152, 211)}, - {"LightYellow", myRGB(255, 255, 224)}, - {"LimeGreen", myRGB(0, 175, 20)}, - {"linen", myRGB(250, 240, 230)}, - {"Magenta", myRGB(255, 0, 255)}, - {"Maroon", myRGB(143, 0, 82)}, - {"MediumAquamarine", myRGB(0, 147, 143)}, - {"MediumBlue", myRGB(50, 50, 204)}, - {"MediumForestGreen", myRGB(50, 129, 75)}, - {"MediumGoldenrod", myRGB(209, 193, 102)}, - {"MediumOrchid", myRGB(189, 82, 189)}, - {"MediumPurple", myRGB(147, 112, 219)}, - {"MediumSeaGreen", myRGB(52, 119, 102)}, - {"MediumSlateBlue", myRGB(106, 106, 141)}, - {"MediumSpringGreen", myRGB(35, 142, 35)}, - {"MediumTurquoise", myRGB(0, 210, 210)}, - {"MediumVioletRed", myRGB(213, 32, 121)}, - {"MidnightBlue", myRGB(47, 47, 100)}, - {"MintCream", myRGB(245, 255, 250)}, - {"MistyRose", myRGB(255, 228, 225)}, - {"moccasin", myRGB(255, 228, 181)}, - {"NavajoWhite", myRGB(255, 222, 173)}, - {"Navy", myRGB(35, 35, 117)}, - {"NavyBlue", myRGB(35, 35, 117)}, - {"OldLace", myRGB(253, 245, 230)}, - {"OliveDrab", myRGB(107, 142, 35)}, - {"Orange", myRGB(255, 135, 0)}, - {"OrangeRed", myRGB(255, 69, 0)}, - {"Orchid", myRGB(239, 132, 239)}, - {"PaleGoldenrod", myRGB(238, 232, 170)}, - {"PaleGreen", myRGB(115, 222, 120)}, - {"PaleTurquoise", myRGB(175, 238, 238)}, - {"PaleVioletRed", myRGB(219, 112, 147)}, - {"PapayaWhip", myRGB(255, 239, 213)}, - {"PeachPuff", myRGB(255, 218, 185)}, - {"peru", myRGB(205, 133, 63)}, - {"Pink", myRGB(255, 181, 197)}, - {"Plum", myRGB(197, 72, 155)}, - {"PowderBlue", myRGB(176, 224, 230)}, - {"purple", myRGB(160, 32, 240)}, - {"Red", myRGB(255, 0, 0)}, - {"RosyBrown", myRGB(188, 143, 143)}, - {"RoyalBlue", myRGB(65, 105, 225)}, - {"SaddleBrown", myRGB(139, 69, 19)}, - {"Salmon", myRGB(233, 150, 122)}, - {"SandyBrown", myRGB(244, 164, 96)}, - {"SeaGreen", myRGB(82, 149, 132)}, - {"seashell", myRGB(255, 245, 238)}, - {"Sienna", myRGB(150, 82, 45)}, - {"SkyBlue", myRGB(114, 159, 255)}, - {"SlateBlue", myRGB(126, 136, 171)}, - {"SlateGray", myRGB(112, 128, 144)}, - {"snow", myRGB(255, 250, 250)}, - {"SpringGreen", myRGB(65, 172, 65)}, - {"SteelBlue", myRGB(84, 112, 170)}, - {"Tan", myRGB(222, 184, 135)}, - {"Thistle", myRGB(216, 191, 216)}, - {"tomato", myRGB(255, 99, 71)}, - {"Transparent", myRGB(0, 0, 1)}, - {"Turquoise", myRGB(25, 204, 223)}, - {"Violet", myRGB(156, 62, 206)}, - {"VioletRed", myRGB(243, 62, 150)}, - {"Wheat", myRGB(245, 222, 179)}, - {"White", myRGB(255, 255, 255)}, - {"WhiteSmoke", myRGB(245, 245, 245)}, - {"Yellow", myRGB(255, 255, 0)}, - {"YellowGreen", myRGB(50, 216, 56)}, - NULL -}; - -static int numTheRGBRecords = 234; @@ -32,11 +32,6 @@ * Developed by Arnaud Le Hors * \*****************************************************************************/ -/* - * The code related to FOR_MSW has been added by - * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94 - */ - /* October 2004, source code review by Thomas Biege <thomas@suse.de> */ #ifdef HAVE_CONFIG_H @@ -76,7 +71,6 @@ LFUNC(storeMaskPixel, int, (Pixel pixel, PixelsMap *pmap, typedef int (*storeFuncPtr)(Pixel pixel, PixelsMap *pmap, unsigned int *index_return); -#ifndef FOR_MSW LFUNC(GetImagePixels, int, (XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap)); @@ -92,11 +86,7 @@ LFUNC(GetImagePixels8, int, (XImage *image, unsigned int width, LFUNC(GetImagePixels1, int, (XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap, storeFuncPtr storeFunc)); -#else /* ndef FOR_MSW */ -LFUNC(MSWGetImagePixels, int, (Display *d, XImage *image, unsigned int width, - unsigned int height, PixelsMap *pmap, - storeFuncPtr storeFunc)); -#endif + LFUNC(ScanTransparentColor, int, (XpmColor *color, unsigned int cpp, XpmAttributes *attributes)); @@ -244,13 +234,8 @@ XpmCreateXpmImageFromImage( * scan shape mask if any */ if (shapeimage) { -#ifndef FOR_MSW ErrorStatus = GetImagePixels1(shapeimage, width, height, &pmap, storeMaskPixel); -#else - ErrorStatus = MSWGetImagePixels(display, shapeimage, width, height, - &pmap, storeMaskPixel); -#endif if (ErrorStatus != XpmSuccess) RETURN(ErrorStatus); } @@ -264,7 +249,6 @@ XpmCreateXpmImageFromImage( */ if (image) { -#ifndef FOR_MSW if (((image->bits_per_pixel | image->depth) == 1) && (image->byte_order == image->bitmap_bit_order)) ErrorStatus = GetImagePixels1(image, width, height, &pmap, @@ -278,10 +262,6 @@ XpmCreateXpmImageFromImage( ErrorStatus = GetImagePixels32(image, width, height, &pmap); } else ErrorStatus = GetImagePixels(image, width, height, &pmap); -#else - ErrorStatus = MSWGetImagePixels(display, image, width, height, &pmap, - storePixel); -#endif if (ErrorStatus != XpmSuccess) RETURN(ErrorStatus); } @@ -409,11 +389,7 @@ ScanOtherColors( Colormap colormap; char *rgb_fname; -#ifndef FOR_MSW xpmRgbName rgbn[MAX_RGBNAMES]; -#else - xpmRgbName *rgbn = NULL; -#endif int rgbn_max = 0; unsigned int i, j, c, i2; XpmColor *color; @@ -465,14 +441,9 @@ ScanOtherColors( } XQueryColors(display, colormap, xcolors, ncolors); -#ifndef FOR_MSW /* read the rgb file if any was specified */ if (rgb_fname) rgbn_max = xpmReadRgbNames(attributes->rgb_fname, rgbn); -#else - /* FOR_MSW: rgb names and values are hardcoded in rgbtab.h */ - rgbn_max = xpmReadRgbNames(NULL, NULL); -#endif if (attributes && attributes->valuemask & XpmColorTable) { colorTable = attributes->colorTable; @@ -535,13 +506,8 @@ ScanOtherColors( else { /* at last store the rgb value */ char buf[BUFSIZ]; -#ifndef FOR_MSW sprintf(buf, "#%04X%04X%04X", xcolor->red, xcolor->green, xcolor->blue); -#else - sprintf(buf, "#%02x%02x%02x", - xcolor->red, xcolor->green, xcolor->blue); -#endif color->c_color = (char *) xpmstrdup(buf); } if (!color->c_color) { @@ -557,7 +523,6 @@ ScanOtherColors( return (XpmSuccess); } -#ifndef FOR_MSW /* * The functions below are written from X11R5 MIT's code (XImUtil.c) * @@ -881,36 +846,6 @@ GetImagePixels1( return (XpmSuccess); } -#else /* ndef FOR_MSW */ -static int -MSWGetImagePixels( - Display *display, - XImage *image, - unsigned int width, - unsigned int height, - PixelsMap *pmap, - int (*storeFunc) (Pixel, PixelsMap*, unsigned int *)) -{ - unsigned int *iptr; - unsigned int x, y; - Pixel pixel; - - iptr = pmap->pixelindex; - - SelectObject(*display, image->bitmap); - for (y = 0; y < height; y++) { - for (x = 0; x < width; x++, iptr++) { - pixel = GetPixel(*display, x, y); - if ((*storeFunc) (pixel, pmap, iptr)) - return (XpmNoMemory); - } - } - return (XpmSuccess); -} - -#endif - -#ifndef FOR_MSW int XpmCreateXpmImageFromPixmap( Display *display, @@ -949,5 +884,3 @@ XpmCreateXpmImageFromPixmap( return (ErrorStatus); } - -#endif /* ndef FOR_MSW */ diff --git a/src/simx.c b/src/simx.c deleted file mode 100644 index c76934b..0000000 --- a/src/simx.c +++ /dev/null @@ -1,293 +0,0 @@ -/* - * Copyright (C) 1989-95 GROUPE BULL - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of GROUPE BULL shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from GROUPE BULL. - */ - -/*****************************************************************************\ -* simx.c: 0.1a * -* * -* This emulates some Xlib functionality for MSW. It's not a general solution, * -* it is close related to XPM-lib. It is only intended to satisfy what is need * -* there. Thus allowing to read XPM files under MS windows. * -* * -* Developed by HeDu 3/94 (hedu@cul-ipn.uni-kiel.de) * -\*****************************************************************************/ - -#ifdef FOR_MSW - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include "xpm.h" -#include "xpmi.h" /* for XpmMalloc */ - -/* - * On DOS size_t is only 2 bytes, thus malloc(size_t s) can only malloc - * 64K. BUT an expression data=malloc(width*height) may result in an - * overflow. So this function takes a long as input, and returns NULL if the - * request is larger than 64K, is size_t is only 2 bytes. - * - * This requires casts like XpmMalloc( (long)width*(long(height)), else it - * might have no effect at all. - */ - -void * -boundCheckingMalloc(long s) -{ - if (sizeof(size_t) == sizeof(long)) { /* same size, just do it */ - return (malloc((size_t) s)); - } else { - if (sizeof(size_t) == 2) { - if (s > 0xFFFF) - return (NULL); /* to large, size_t with 2 bytes - * only allows 16 bits */ - else - return (malloc((size_t) s)); - } else { /* it's not a long, not 2 bytes, - * what is it ??? */ - return (malloc((size_t) s)); - } - } -} -void * -boundCheckingCalloc(long num, long s) -{ - if (sizeof(size_t) == sizeof(long)) { /* same size, just do it */ - return (calloc((size_t) num, (size_t) s)); - } else { - if (sizeof(size_t) == 2) { - if (s > 0xFFFF || num * s > 0xFFFF) - return (NULL); /* to large, size_t with 2 bytes - * only allows 16 bits */ - else - return (calloc((size_t) num, (size_t) s)); - } else { /* it's not a long, not 2 bytes, - * what is it ??? */ - return (calloc((size_t) num, (size_t) s)); - } - } -} -void * -boundCheckingRealloc(void *p, long s) -{ - if (sizeof(size_t) == sizeof(long)) { /* same size, just do it */ - return (realloc(p, (size_t) s)); - } else { - if (sizeof(size_t) == 2) { - if (s > 0xFFFF) - return (NULL); /* to large, size_t with 2 bytes - * only allows 16 bits */ - else - return (realloc(p, (size_t) s)); - } else { /* it's not a long, not 2 bytes, - * what is it ??? */ - return (realloc(p, (size_t) s)); - } - } -} - -/* static Visual theVisual = { 0 }; */ -Visual * -XDefaultVisual(Display *display, Screen *screen) -{ - return (NULL); /* struct could contain info about - * MONO, GRAY, COLOR */ -} - -Screen * -XDefaultScreen(Display *d) -{ - return (NULL); -} - -/* I get only 1 plane but 8 bits per pixel, - so I think BITSPIXEL should be depth */ -int -XDefaultDepth(Display *display, Screen *screen) -{ - int d, b; - - b = GetDeviceCaps(*display, BITSPIXEL); - d = GetDeviceCaps(*display, PLANES); - return (b); -} - -Colormap * -XDefaultColormap(Display *display, Screen *screen) -{ - return (NULL); -} - -/* convert hex color names, - wrong digits (not a-f,A-F,0-9) are treated as zero */ -static int -hexCharToInt(c) -{ - int r; - - if (c >= '0' && c <= '9') - r = c - '0'; - else if (c >= 'a' && c <= 'f') - r = c - 'a' + 10; - else if (c >= 'A' && c <= 'F') - r = c - 'A' + 10; - else - r = 0; - - return (r); -} - -static int -rgbFromHex(char *hex, int *r, int *g, int *b) -{ - int len; - - if (hex == NULL || hex[0] != '#') - return (0); - - len = strlen(hex); - if (len == 3 + 1) { - *r = hexCharToInt(hex[1]); - *g = hexCharToInt(hex[2]); - *b = hexCharToInt(hex[3]); - } else if (len == 6 + 1) { - *r = hexCharToInt(hex[1]) * 16 + hexCharToInt(hex[2]); - *g = hexCharToInt(hex[3]) * 16 + hexCharToInt(hex[4]); - *b = hexCharToInt(hex[5]) * 16 + hexCharToInt(hex[6]); - } else if (len == 12 + 1) { - /* it's like c #32329999CCCC */ - /* so for now only take two digits */ - *r = hexCharToInt(hex[1]) * 16 + hexCharToInt(hex[2]); - *g = hexCharToInt(hex[5]) * 16 + hexCharToInt(hex[6]); - *b = hexCharToInt(hex[9]) * 16 + hexCharToInt(hex[10]); - } else - return (0); - - return (1); -} - -/* Color related functions */ -int -XParseColor(Display *d, Colormap *cmap, char *name, XColor *color) -{ - int r, g, b; /* only 8 bit values used */ - int okay; - -/* TODO: use colormap via PALETTE */ - /* parse name either in table or #RRGGBB #RGB */ - if (name == NULL) - return (0); - - if (name[0] == '#') { /* a hex string */ - okay = rgbFromHex(name, &r, &g, &b); - } else { - okay = xpmGetRGBfromName(name, &r, &g, &b); - } - - if (okay) { - color->pixel = RGB(r, g, b); - color->red = (BYTE) r; - color->green = (BYTE) g; - color->blue = (BYTE) b; - return (1); - } else - return (0); /* --> ColorError */ -} - - -int -XAllocColor(Display *d, Colormap cmap, XColor *color) -{ -/* colormap not used yet so color->pixel is the real COLORREF (RBG) and not an - index in some colormap as in X */ - return (1); -} -void -XQueryColors(Display *display, Colormap *colormap, - XColor *xcolors, int ncolors) -{ -/* under X this fills the rgb values to given .pixel */ -/* since there no colormap use FOR_MSW (not yet!!), rgb is plain encoded */ - XColor *xc = xcolors; - int i; - - for (i = 0; i < ncolors; i++, xc++) { - xc->red = GetRValue(xc->pixel); - xc->green = GetGValue(xc->pixel); - xc->blue = GetBValue(xc->pixel); - } - return; -} -int -XFreeColors(Display *d, Colormap cmap, - unsigned long pixels[], int npixels, unsigned long planes) -{ - /* no colormap yet */ - return (0); /* correct ??? */ -} - -/* XImage functions */ -XImage * -XCreateImage(Display *d, Visual *v, - int depth, int format, - int x, int y, int width, int height, - int pad, int foo) -{ - XImage *img = (XImage *) XpmMalloc(sizeof(XImage)); - - if (img) { - /*JW: This is what it should be, but the picture comes out - just black!? It appears to be doing monochrome reduction, - but I've got no clue why. Using CreateBitmap() is supposed - to be slower, but otherwise ok - if ( depth == GetDeviceCaps(*d, BITSPIXEL) ) { - img->bitmap = CreateCompatibleBitmap(*d, width, height); - } else*/ { - img->bitmap = CreateBitmap(width, height, 1 /* plane */ , - depth /* bits per pixel */ , NULL); - } - img->width = width; - img->height = height; - img->depth = depth; - } - return (img); - -} - -void -XImageFree(XImage *img) -{ - if (img) { - XpmFree(img); - } -} -void -XDestroyImage(XImage *img) -{ - if (img) { - DeleteObject(img->bitmap); /* check return ??? */ - XImageFree(img); - } -} - -#endif diff --git a/src/simx.h b/src/simx.h deleted file mode 100644 index 7c4c4b9..0000000 --- a/src/simx.h +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (C) 1989-95 GROUPE BULL - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of GROUPE BULL shall not be - * used in advertising or otherwise to promote the sale, use or other dealings - * in this Software without prior written authorization from GROUPE BULL. - */ - -/*****************************************************************************\ -* simx.h: 0.1a * -* * -* This emulates some Xlib functionality for MSW. It's not a general solution, * -* it is close related to XPM-lib. It is only intended to satisfy what is need * -* there. Thus allowing to read XPM files under MS windows. * -* * -* Developed by HeDu 3/94 (hedu@cul-ipn.uni-kiel.de) * -\*****************************************************************************/ - - -#ifndef _SIMX_H -#define _SIMX_H - -#ifdef FOR_MSW - -#include "windows.h" /* MS windows GDI types */ -#define _XFUNCPROTOBEGIN -#define _XFUNCPROTOEND -#define NO_ZPIPE - -/* - * minimal portability layer between ansi and KR C - */ -/* this comes from xpm.h, and is here again, to avoid complicated - includes, since this is included from xpm.h */ -/* these defines get undefed at the end of this file */ -#if __STDC__ || defined(__cplusplus) || defined(c_plusplus) - /* ANSI || C++ */ -#define FUNC(f, t, p) extern t f p -#define LFUNC(f, t, p) static t f p -#else /* k&R */ -#define FUNC(f, t, p) extern t f() -#define LFUNC(f, t, p) static t f() -#endif - - -FUNC(boundCheckingMalloc, void *, (long s)); -FUNC(boundCheckingCalloc, void *, (long num, long s)); -FUNC(boundCheckingRealloc, void *, (void *p, long s)); - -/* define MSW types for X window types, - I don't know much about MSW, but the following defines do the job */ - -typedef HDC Display; /* this should be similar */ -typedef void *Screen; /* not used */ -typedef void *Visual; /* not used yet, is for GRAY, COLOR, - * MONO */ - -typedef void *Colormap; /* should be COLORPALETTE, not done - * yet */ - -typedef COLORREF Pixel; - -#define PIXEL_ALREADY_TYPEDEFED /* to let xpm.h know about it */ - -typedef struct { - Pixel pixel; - BYTE red, green, blue; -} XColor; - -typedef struct { - HBITMAP bitmap; - unsigned int width; - unsigned int height; - unsigned int depth; -} XImage; - -#if defined(__cplusplus) || defined(c_plusplus) -extern "C" { -#endif -/* some replacements for X... functions */ - -/* XDefaultXXX */ - FUNC(XDefaultVisual, Visual *, (Display *display, Screen *screen)); - FUNC(XDefaultScreen, Screen *, (Display *d)); - FUNC(XDefaultColormap, Colormap *, (Display *display, Screen *screen)); - FUNC(XDefaultDepth, int, (Display *d, Screen *s)); - -/* color related */ - FUNC(XParseColor, int, (Display *, Colormap *, char *, XColor *)); - FUNC(XAllocColor, int, (Display *, Colormap, XColor *)); - FUNC(XQueryColors, void, (Display *display, Colormap *colormap, - XColor *xcolors, int ncolors)); - FUNC(XFreeColors, int, (Display *d, Colormap cmap, - unsigned long pixels[], - int npixels, unsigned long planes)); -/* XImage */ - FUNC(XCreateImage, XImage *, (Display *, Visual *, int depth, int format, - int x, int y, int width, int height, - int pad, int foo)); - -/* free and destroy bitmap */ - FUNC(XDestroyImage, void /* ? */ , (XImage *)); -/* free only, bitmap remains */ - FUNC(XImageFree, void, (XImage *)); -#if defined(__cplusplus) || defined(c_plusplus) -} /* end of extern "C" */ -#endif /* cplusplus */ - -#define ZPixmap 1 /* not really used */ -#define XYBitmap 1 /* not really used */ - -#ifndef True -#define True 1 -#define False 0 -#endif -#ifndef Bool -typedef BOOL Bool; /* take MSW bool */ -#endif -/* make these local here, simx.c gets the same from xpm.h */ -#undef LFUNC -#undef FUNC - -/* Some functions and constants that have non-standard names in the - MS library. */ -#define bzero(addr,sz) memset(addr, 0, sz) -#define close _close -#define fdopen _fdopen -#define index strchr -#define open _open -#define O_RDONLY _O_RDONLY -#define rindex strrchr -#define strdup _strdup - - -#endif /* def FOR_MSW */ - -#endif /* _SIMX_H */ |