Added xpm directory.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1083 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1998-11-29 21:16:36 +00:00
parent a974387a22
commit cfbe03c9c3
31 changed files with 9091 additions and 0 deletions
+704
View File
File diff suppressed because it is too large Load Diff
+31
View File
@@ -0,0 +1,31 @@
/*
* Copyright (C) 1989-94 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.
*/
Arnaud LE HORS BULL Research FRANCE -- Koala Project
(XPM - X PixMap format version 2 & 3)
Internet: lehors@sophia.inria.fr
Surface Mail: Arnaud LE HORS, INRIA - Sophia Antipolis,
2004, route des Lucioles, 06565 Valbonne Cedex -- FRANCE
Voice phone: (33) 93.65.77.71, Fax: (33) 93 65 77 66, Telex: 97 00 50 F
+324
View File
@@ -0,0 +1,324 @@
/*
* Copyright (C) 1989-94 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.
*/
/*****************************************************************************\
* XpmCrBufFrI.c: *
* *
* XPM library *
* Scan an image and possibly its mask and create an XPM buffer *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#include "xpm34p.h"
#ifdef VMS
#include "sys$library:string.h"
#else
#if defined(SYSV) || defined(SVR4)
#include <string.h>
#else
#include <strings.h>
#endif
#endif
LFUNC(WriteColors, int, (char **dataptr, unsigned int *data_size,
unsigned int *used_size, XpmColor *colors,
unsigned int ncolors, unsigned int cpp));
LFUNC(WritePixels, void, (char *dataptr, unsigned int *used_size,
unsigned int width, unsigned int height,
unsigned int cpp, unsigned int *pixels,
XpmColor *colors));
LFUNC(WriteExtensions, void, (char *dataptr, unsigned int *used_size,
XpmExtension *ext, unsigned int num));
LFUNC(ExtensionsSize, int, (XpmExtension *ext, unsigned int num));
LFUNC(CommentsSize, int, (XpmInfo *info));
int
XpmCreateBufferFromImage(Display *display, char **buffer_return, XImage *image,
XImage *shapeimage, XpmAttributes *attributes)
{
XpmImage xpmimage;
XpmInfo info;
int ErrorStatus;
/* initialize return value */
if (buffer_return)
*buffer_return = NULL;
/* create an XpmImage from the image */
ErrorStatus = XpmCreateXpmImageFromImage(display, image, shapeimage,
&xpmimage, attributes);
if (ErrorStatus != XpmSuccess)
return (ErrorStatus);
/* create the buffer from the XpmImage */
if (attributes) {
xpmSetInfo(&info, attributes);
ErrorStatus =
XpmCreateBufferFromXpmImage(buffer_return, &xpmimage, &info);
} else
ErrorStatus =
XpmCreateBufferFromXpmImage(buffer_return, &xpmimage, NULL);
/* free the XpmImage */
XpmFreeXpmImage(&xpmimage);
return (ErrorStatus);
}
#undef RETURN
#define RETURN(status) \
{ \
if (ptr) \
XpmFree(ptr); \
return(status); \
}
int
XpmCreateBufferFromXpmImage(char **buffer_return, XpmImage *image, XpmInfo *info)
{
/* calculation variables */
int ErrorStatus;
char buf[BUFSIZ];
unsigned int cmts, extensions, ext_size = 0;
unsigned int l, cmt_size = 0;
char *ptr = NULL, *p;
unsigned int ptr_size, used_size;
*buffer_return = NULL;
cmts = info && (info->valuemask & XpmComments);
extensions = info && (info->valuemask & XpmExtensions)
&& info->nextensions;
/* compute the extensions and comments size */
if (extensions)
ext_size = ExtensionsSize(info->extensions, info->nextensions);
if (cmts)
cmt_size = CommentsSize(info);
/* write the header line */
sprintf(buf, "/* XPM */\nstatic char * image_name[] = {\n");
used_size = strlen(buf);
ptr_size = used_size + ext_size + cmt_size + 1;
ptr = (char *) XpmMalloc(ptr_size);
if (!ptr)
return XpmNoMemory;
strcpy(ptr, buf);
/* write the values line */
if (cmts && info->hints_cmt) {
sprintf(ptr + used_size, "/*%s*/\n", info->hints_cmt);
used_size += strlen(info->hints_cmt) + 5;
}
sprintf(buf, "\"%d %d %d %d", image->width, image->height,
image->ncolors, image->cpp);
l = strlen(buf);
if (info && (info->valuemask & XpmHotspot)) {
sprintf(buf + l, " %d %d", info->x_hotspot, info->y_hotspot);
l = strlen(buf);
}
if (extensions) {
sprintf(buf + l, " XPMEXT");
l = strlen(buf);
}
sprintf(buf + l, "\",\n");
l = strlen(buf);
ptr_size += l;
p = (char *) XpmRealloc(ptr, ptr_size);
if (!p)
RETURN(XpmNoMemory);
ptr = p;
strcpy(ptr + used_size, buf);
used_size += l;
/* write colors */
if (cmts && info->colors_cmt) {
sprintf(ptr + used_size, "/*%s*/\n", info->colors_cmt);
used_size += strlen(info->colors_cmt) + 5;
}
ErrorStatus = WriteColors(&ptr, &ptr_size, &used_size,
image->colorTable, image->ncolors, image->cpp);
if (ErrorStatus != XpmSuccess)
RETURN(ErrorStatus);
/*
* now we know the exact size we needed, realloc the data 4 = 1 (for
* '"') + 3 (for '",\n') 1 = - 2 is because the last line does not end
* with ',\n' + 3 (for '};\n')
*/
ptr_size += image->height * (image->width * image->cpp + 4) + 1;
p = (char *) XpmRealloc(ptr, ptr_size);
if (!p)
RETURN(XpmNoMemory);
ptr = p;
/* print pixels */
if (cmts && info->pixels_cmt) {
sprintf(ptr + used_size, "/*%s*/\n", info->pixels_cmt);
used_size += strlen(info->pixels_cmt) + 5;
}
WritePixels(ptr + used_size, &used_size, image->width, image->height,
image->cpp, image->data, image->colorTable);
/* print extensions */
if (extensions)
WriteExtensions(ptr + used_size, &used_size,
info->extensions, info->nextensions);
/* close the array */
sprintf(ptr + used_size, "};\n");
*buffer_return = ptr;
return (XpmSuccess);
}
static int
WriteColors(char **dataptr, unsigned int *data_size, unsigned int *used_size,
XpmColor *colors, unsigned int ncolors, unsigned int cpp)
{
char buf[BUFSIZ];
unsigned int a, key, l;
char *s, *s2;
char **defaults;
*buf = '"';
for (a = 0; a < ncolors; a++, colors++) {
defaults = (char **) colors;
s = buf + 1;
strncpy(s, *defaults++, cpp);
s += cpp;
for (key = 1; key <= NKEYS; key++, defaults++) {
if (s2 = *defaults) {
sprintf(s, "\t%s %s", xpmColorKeys[key - 1], s2);
s += strlen(s);
}
}
strcpy(s, "\",\n");
l = strlen(buf);
s = (char *) XpmRealloc(*dataptr, *data_size + l);
if (!s)
return (XpmNoMemory);
*data_size += l;
strcpy(s + *used_size, buf);
*used_size += l;
*dataptr = s;
}
return (XpmSuccess);
}
static void
WritePixels(char *dataptr, unsigned int *used_size, unsigned int width, unsigned int height,
unsigned int cpp, unsigned int *pixels, XpmColor *colors)
{
char *s = dataptr;
unsigned int x, y, h;
h = height - 1;
for (y = 0; y < h; y++) {
*s++ = '"';
for (x = 0; x < width; x++, pixels++) {
strncpy(s, colors[*pixels].string, cpp);
s += cpp;
}
strcpy(s, "\",\n");
s += 3;
}
/* duplicate some code to avoid a test in the loop */
*s++ = '"';
for (x = 0; x < width; x++, pixels++) {
strncpy(s, colors[*pixels].string, cpp);
s += cpp;
}
*s++ = '"';
*used_size += s - dataptr;
}
static int
ExtensionsSize(XpmExtension *ext, unsigned int num)
{
unsigned int x, y, a, size;
char **line;
size = 0;
for (x = 0; x < num; x++, ext++) {
/* 11 = 10 (for ',\n"XPMEXT ') + 1 (for '"') */
size += strlen(ext->name) + 11;
a = ext->nlines;
for (y = 0, line = ext->lines; y < a; y++, line++)
/* 4 = 3 (for ',\n"') + 1 (for '"') */
size += strlen(*line) + 4;
}
/* 13 is for ',\n"XPMENDEXT"' */
return size + 13;
}
static void
WriteExtensions(char *dataptr, unsigned int *used_size, XpmExtension *ext, unsigned int num)
{
unsigned int x, y, a;
char **line;
char *s = dataptr;
for (x = 0; x < num; x++, ext++) {
sprintf(s, ",\n\"XPMEXT %s\"", ext->name);
s += strlen(ext->name) + 11;
a = ext->nlines;
for (y = 0, line = ext->lines; y < a; y++, line++) {
sprintf(s, ",\n\"%s\"", *line);
s += strlen(*line) + 4;
}
}
strcpy(s, ",\n\"XPMENDEXT\"");
*used_size += s - dataptr + 13;
}
static int
CommentsSize(XpmInfo *info)
{
int size = 0;
/* 5 = 2 (for "/_*") + 3 (for "*_/\n") */
if (info->hints_cmt)
size += 5 + strlen(info->hints_cmt);
if (info->colors_cmt)
size += 5 + strlen(info->colors_cmt);
if (info->pixels_cmt)
size += 5 + strlen(info->pixels_cmt);
return size;
}
+82
View File
@@ -0,0 +1,82 @@
/*
* Copyright (C) 1989-94 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.
*/
/*****************************************************************************\
* XpmCrBufFrP.c: *
* *
* XPM library *
* Scan a pixmap and possibly its mask and create an XPM buffer *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#ifndef FOR_MSW
#include "xpm34p.h"
#ifdef VMS
#include "sys$library:string.h"
#else
#if defined(SYSV) || defined(SVR4)
#include <string.h>
#else
#include <strings.h>
#endif
#endif
int
XpmCreateBufferFromPixmap(Display *display, char **buffer_return, Pixmap pixmap, Pixmap shapemask,
XpmAttributes *attributes)
{
XImage *ximage = NULL;
XImage *shapeimage = NULL;
unsigned int width = 0;
unsigned int height = 0;
int ErrorStatus;
/* get geometry */
if (attributes && attributes->valuemask & XpmSize) {
width = attributes->width;
height = attributes->height;
}
/* get the ximages */
if (pixmap)
xpmCreateImageFromPixmap(display, pixmap, &ximage, &width, &height);
if (shapemask)
xpmCreateImageFromPixmap(display, shapemask, &shapeimage,
&width, &height);
/* create the buffer */
ErrorStatus = XpmCreateBufferFromImage(display, buffer_return, ximage,
shapeimage, attributes);
/* destroy the ximages */
if (ximage)
XDestroyImage(ximage);
if (shapeimage)
XDestroyImage(shapeimage);
return (ErrorStatus);
}
#endif
+304
View File
@@ -0,0 +1,304 @@
/*
* Copyright (C) 1989-94 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.
*/
/*****************************************************************************\
* XpmCrDataFI.c: *
* *
* XPM library *
* Scan an image and possibly its mask and create an XPM array *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#include "xpm34p.h"
#ifdef VMS
#include "sys$library:string.h"
#else
#if defined(SYSV) || defined(SVR4)
#include <string.h>
#else
#include <strings.h>
#endif
#endif
LFUNC(CreateColors, int, (char **dataptr, unsigned int *data_size,
XpmColor *colors, unsigned int ncolors,
unsigned int cpp));
LFUNC(CreatePixels, void, (char **dataptr, unsigned int width,
unsigned int height, unsigned int cpp,
unsigned int *pixels, XpmColor *colors));
LFUNC(CountExtensions, void, (XpmExtension *ext, unsigned int num,
unsigned int *ext_size,
unsigned int *ext_nlines));
LFUNC(CreateExtensions, void, (char **dataptr, unsigned int offset,
XpmExtension *ext, unsigned int num,
unsigned int ext_nlines));
int
XpmCreateDataFromImage(Display *display, char ***data_return, XImage *image,
XImage *shapeimage, XpmAttributes *attributes)
{
XpmImage xpmimage;
XpmInfo info;
int ErrorStatus;
/* initialize return value */
if (data_return)
*data_return = NULL;
/* create an XpmImage from the image */
ErrorStatus = XpmCreateXpmImageFromImage(display, image, shapeimage,
&xpmimage, attributes);
if (ErrorStatus != XpmSuccess)
return (ErrorStatus);
/* create the data from the XpmImage */
if (attributes) {
xpmSetInfo(&info, attributes);
ErrorStatus = XpmCreateDataFromXpmImage(data_return, &xpmimage, &info);
} else
ErrorStatus = XpmCreateDataFromXpmImage(data_return, &xpmimage, NULL);
/* free the XpmImage */
XpmFreeXpmImage(&xpmimage);
return (ErrorStatus);
}
#undef RETURN
#define RETURN(status) \
{ \
if (header) { \
for (l = 0; l < header_nlines; l++) \
if (header[l]) \
XpmFree(header[l]); \
XpmFree(header); \
} \
return(status); \
}
int
XpmCreateDataFromXpmImage(char ***data_return, XpmImage *image, XpmInfo *info)
{
/* calculation variables */
int ErrorStatus;
char buf[BUFSIZ];
char **header = NULL, **data, **sptr, **sptr2, *s;
unsigned int header_size, header_nlines;
unsigned int data_size, data_nlines;
unsigned int extensions = 0, ext_size = 0, ext_nlines = 0;
unsigned int offset, l, n;
*data_return = NULL;
extensions = info && (info->valuemask & XpmExtensions)
&& info->nextensions;
/* compute the number of extensions lines and size */
if (extensions)
CountExtensions(info->extensions, info->nextensions,
&ext_size, &ext_nlines);
/*
* alloc a temporary array of char pointer for the header section which
* is the hints line + the color table lines
*/
header_nlines = 1 + image->ncolors;
header_size = sizeof(char *) * header_nlines;
header = (char **) XpmCalloc(header_size, sizeof(char *));
if (!header)
return (XpmNoMemory);
/* print the hints line */
s = buf;
sprintf(s, "%d %d %d %d", image->width, image->height,
image->ncolors, image->cpp);
s += strlen(s);
if (info && (info->valuemask & XpmHotspot)) {
sprintf(s, " %d %d", info->x_hotspot, info->y_hotspot);
s += strlen(s);
}
if (extensions)
sprintf(s, " XPMEXT");
l = strlen(buf) + 1;
*header = (char *) XpmMalloc(l);
if (!*header)
RETURN(XpmNoMemory);
header_size += l;
strcpy(*header, buf);
/* print colors */
ErrorStatus = CreateColors(header + 1, &header_size,
image->colorTable, image->ncolors, image->cpp);
if (ErrorStatus != XpmSuccess)
RETURN(ErrorStatus);
/* now we know the size needed, alloc the data and copy the header lines */
offset = image->width * image->cpp + 1;
data_size = header_size + (image->height + ext_nlines) * sizeof(char *)
+ image->height * offset + ext_size;
data = (char **) XpmMalloc(data_size);
if (!data)
RETURN(XpmNoMemory);
data_nlines = header_nlines + image->height + ext_nlines;
*data = (char *) (data + data_nlines);
n = image->ncolors;
for (l = 0, sptr = data, sptr2 = header; l <= n; l++, sptr++, sptr2++) {
strcpy(*sptr, *sptr2);
*(sptr + 1) = *sptr + strlen(*sptr2) + 1;
}
/* print pixels */
data[header_nlines] = (char *) data + header_size
+ (image->height + ext_nlines) * sizeof(char *);
CreatePixels(data + header_nlines, image->width, image->height,
image->cpp, image->data, image->colorTable);
/* print extensions */
if (extensions)
CreateExtensions(data + header_nlines + image->height - 1, offset,
info->extensions, info->nextensions,
ext_nlines);
*data_return = data;
RETURN(XpmSuccess);
}
static int
CreateColors(char **dataptr, unsigned int *data_size, XpmColor *colors, unsigned int ncolors, unsigned int cpp)
{
char buf[BUFSIZ];
unsigned int a, key, l;
char *s, *s2;
char **defaults;
for (a = 0; a < ncolors; a++, colors++, dataptr++) {
defaults = (char **) colors;
strncpy(buf, *defaults++, cpp);
s = buf + cpp;
for (key = 1; key <= NKEYS; key++, defaults++) {
if (s2 = *defaults) {
sprintf(s, "\t%s %s", xpmColorKeys[key - 1], s2);
s += strlen(s);
}
}
l = strlen(buf) + 1;
s = (char *) XpmMalloc(l);
if (!s)
return (XpmNoMemory);
*data_size += l;
strcpy(s, buf);
*dataptr = s;
}
return (XpmSuccess);
}
static void
CreatePixels(char **dataptr, unsigned int width, unsigned int height, unsigned int cpp,
unsigned int *pixels, XpmColor *colors)
{
char *s;
unsigned int x, y, h, offset;
h = height - 1;
offset = width * cpp + 1;
for (y = 0; y < h; y++, dataptr++) {
s = *dataptr;
for (x = 0; x < width; x++, pixels++) {
strncpy(s, colors[*pixels].string, cpp);
s += cpp;
}
*s = '\0';
*(dataptr + 1) = *dataptr + offset;
}
/* duplicate some code to avoid a test in the loop */
s = *dataptr;
for (x = 0; x < width; x++, pixels++) {
strncpy(s, colors[*pixels].string, cpp);
s += cpp;
}
*s = '\0';
}
static void
CountExtensions(XpmExtension *ext, unsigned int num, unsigned int *ext_size, unsigned int *ext_nlines)
{
unsigned int x, y, a, size, nlines;
char **line;
size = 0;
nlines = 0;
for (x = 0; x < num; x++, ext++) {
/* 1 for the name */
nlines += ext->nlines + 1;
/* 8 = 7 (for "XPMEXT ") + 1 (for 0) */
size += strlen(ext->name) + 8;
a = ext->nlines;
for (y = 0, line = ext->lines; y < a; y++, line++)
size += strlen(*line) + 1;
}
/* 10 and 1 are for the ending "XPMENDEXT" */
*ext_size = size + 10;
*ext_nlines = nlines + 1;
}
static void
CreateExtensions(char **dataptr, unsigned int offset, XpmExtension *ext, unsigned int num, unsigned int ext_nlines)
{
unsigned int x, y, a, b;
char **line;
*(dataptr + 1) = *dataptr + offset;
dataptr++;
a = 0;
for (x = 0; x < num; x++, ext++) {
sprintf(*dataptr, "XPMEXT %s", ext->name);
a++;
if (a < ext_nlines)
*(dataptr + 1) = *dataptr + strlen(ext->name) + 8;
dataptr++;
b = ext->nlines;
for (y = 0, line = ext->lines; y < b; y++, line++) {
strcpy(*dataptr, *line);
a++;
if (a < ext_nlines)
*(dataptr + 1) = *dataptr + strlen(*line) + 1;
dataptr++;
}
}
strcpy(*dataptr, "XPMENDEXT");
}
+83
View File
@@ -0,0 +1,83 @@
/*
* Copyright (C) 1989-94 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.
*/
/*****************************************************************************\
* XpmCrDataFP.c: *
* *
* XPM library *
* Scan a pixmap and possibly its mask and create an XPM array *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#ifndef FOR_MSW
#include "xpm34p.h"
#ifdef VMS
#include "sys$library:string.h"
#else
#if defined(SYSV) || defined(SVR4)
#include <string.h>
#else
#include <strings.h>
#endif
#endif
int
XpmCreateDataFromPixmap(Display *display, char ***data_return, Pixmap pixmap,
Pixmap shapemask, XpmAttributes *attributes)
{
XImage *ximage = NULL;
XImage *shapeimage = NULL;
unsigned int width = 0;
unsigned int height = 0;
int ErrorStatus;
/* get geometry */
if (attributes && attributes->valuemask & XpmSize) {
width = attributes->width;
height = attributes->height;
}
/* get the ximages */
if (pixmap)
xpmCreateImageFromPixmap(display, pixmap, &ximage, &width, &height);
if (shapemask)
xpmCreateImageFromPixmap(display, shapemask, &shapeimage,
&width, &height);
/* create the data */
ErrorStatus = XpmCreateDataFromImage(display, data_return, ximage,
shapeimage, attributes);
/* destroy the ximages */
if (ximage)
XDestroyImage(ximage);
if (shapeimage)
XDestroyImage(shapeimage);
return (ErrorStatus);
}
#endif
+1461
View File
File diff suppressed because it is too large Load Diff
+90
View File
@@ -0,0 +1,90 @@
/*
* Copyright (C) 1989-94 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.
*/
/*****************************************************************************\
* XpmCrIFrBuf.c: *
* *
* XPM library *
* Parse an Xpm buffer (file in memory) and create the image and possibly its *
* mask *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#include "xpm34p.h"
int
XpmCreateImageFromBuffer(Display *display, char *buffer, XImage **image_return,
XImage **shapeimage_return, XpmAttributes *attributes)
{
XpmImage image;
XpmInfo info;
int ErrorStatus;
/* create an XpmImage from the buffer */
if (attributes) {
xpmInitAttributes(attributes);
xpmSetInfoMask(&info, attributes);
ErrorStatus = XpmCreateXpmImageFromBuffer(buffer, &image, &info);
} else
ErrorStatus = XpmCreateXpmImageFromBuffer(buffer, &image, NULL);
if (ErrorStatus != XpmSuccess)
return (ErrorStatus);
/* create the related ximages */
ErrorStatus = XpmCreateImageFromXpmImage(display, &image,
image_return, shapeimage_return,
attributes);
if (attributes) {
if (ErrorStatus >= 0) /* no fatal error */
xpmSetAttributes(attributes, &image, &info);
XpmFreeXpmInfo(&info);
}
/* free the XpmImage */
XpmFreeXpmImage(&image);
return (ErrorStatus);
}
int
XpmCreateXpmImageFromBuffer(char *buffer, XpmImage *image, XpmInfo *info)
{
xpmData mdata;
int ErrorStatus;
/* init returned values */
xpmInitXpmImage(image);
xpmInitXpmInfo(info);
/* open buffer to read */
xpmOpenBuffer(buffer, &mdata);
/* create the XpmImage from the XpmData */
ErrorStatus = xpmParseData(&mdata, image, info);
xpmDataClose(&mdata);
return (ErrorStatus);
}
+89
View File
@@ -0,0 +1,89 @@
/*
* Copyright (C) 1989-94 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.
*/
/*****************************************************************************\
* XpmCrIFrData.c: *
* *
* XPM library *
* Parse an Xpm array and create the image and possibly its mask *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#include "xpm34p.h"
int
XpmCreateImageFromData(Display *display, char **data, XImage **image_return,
XImage **shapeimage_return, XpmAttributes *attributes)
{
XpmImage image;
XpmInfo info;
int ErrorStatus;
/* create an XpmImage from the file */
if (attributes) {
xpmInitAttributes(attributes);
xpmSetInfoMask(&info, attributes);
ErrorStatus = XpmCreateXpmImageFromData(data, &image, &info);
} else
ErrorStatus = XpmCreateXpmImageFromData(data, &image, NULL);
if (ErrorStatus != XpmSuccess)
return (ErrorStatus);
/* create the related ximages */
ErrorStatus = XpmCreateImageFromXpmImage(display, &image,
image_return, shapeimage_return,
attributes);
if (attributes) {
if (ErrorStatus >= 0) /* no fatal error */
xpmSetAttributes(attributes, &image, &info);
XpmFreeXpmInfo(&info);
}
XpmFreeXpmImage(&image);
return (ErrorStatus);
}
int
XpmCreateXpmImageFromData(char **data, XpmImage *image, XpmInfo *info)
{
xpmData mdata;
int ErrorStatus;
/* init returned values */
xpmInitXpmImage(image);
xpmInitXpmInfo(info);
/* open data */
xpmOpenArray(data, &mdata);
/* create the XpmImage from the XpmData */
ErrorStatus = xpmParseData(&mdata, image, info);
xpmDataClose(&mdata);
return (ErrorStatus);
}
+72
View File
@@ -0,0 +1,72 @@
/*
* Copyright (C) 1989-94 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.
*/
/*****************************************************************************\
* XpmCrPFrBuf.c: *
* *
* XPM library *
* Parse an Xpm buffer and create the pixmap and possibly its mask *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#ifndef FOR_MSW
#include "xpm34p.h"
int
XpmCreatePixmapFromBuffer(Display *display, Drawable d, char *buffer, Pixmap *pixmap_return,
Pixmap *shapemask_return, XpmAttributes *attributes)
{
XImage *ximage, *shapeimage;
int ErrorStatus;
/* initialize return values */
if (pixmap_return)
*pixmap_return = 0;
if (shapemask_return)
*shapemask_return = 0;
/* create the images */
ErrorStatus = XpmCreateImageFromBuffer(display, buffer,
(pixmap_return ? &ximage : NULL),
(shapemask_return ?
&shapeimage : NULL),
attributes);
if (ErrorStatus < 0) /* fatal error */
return (ErrorStatus);
/* create the pixmaps and destroy images */
if (pixmap_return && ximage) {
xpmCreatePixmapFromImage(display, d, ximage, pixmap_return);
XDestroyImage(ximage);
}
if (shapemask_return && shapeimage) {
xpmCreatePixmapFromImage(display, d, shapeimage, shapemask_return);
XDestroyImage(shapeimage);
}
return (ErrorStatus);
}
#endif
+75
View File
@@ -0,0 +1,75 @@
/*
* Copyright (C) 1989-94 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.
*/
/*****************************************************************************\
* XpmCrPFrData.c: *
* *
* XPM library *
* Parse an Xpm array and create the pixmap and possibly its mask *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#include "xpm34p.h"
#ifndef FOR_MSW
int
XpmCreatePixmapFromData(Display *display, Drawable d, char **data, Pixmap *pixmap_return,
Pixmap *shapemask_return, XpmAttributes *attributes)
{
XImage *ximage, *shapeimage;
int ErrorStatus;
/* initialize return values */
if (pixmap_return)
*pixmap_return = 0;
if (shapemask_return)
*shapemask_return = 0;
/* create the images */
ErrorStatus = XpmCreateImageFromData(display, data,
(pixmap_return ? &ximage : NULL),
(shapemask_return ?
&shapeimage : NULL),
attributes);
if (ErrorStatus != XpmSuccess)
return (ErrorStatus);
if (ErrorStatus < 0) /* fatal error */
return (ErrorStatus);
/* create the pixmaps and destroy images */
if (pixmap_return && ximage) {
xpmCreatePixmapFromImage(display, d, ximage, pixmap_return);
XDestroyImage(ximage);
}
if (shapemask_return && shapeimage) {
xpmCreatePixmapFromImage(display, d, shapeimage, shapemask_return);
XDestroyImage(shapeimage);
}
return (ErrorStatus);
}
#endif
+627
View File
File diff suppressed because it is too large Load Diff
+47
View File
@@ -0,0 +1,47 @@
CHANGES
COPYRIGHT
FILES
Imakefile
Makefile.noXtree
README
README.MSW
namecvt
lib
lib/Imakefile
lib/Makefile.noXtree
lib/XpmCrBufFrI.c
lib/XpmCrBufFrP.c
lib/XpmCrDataFrI.c
lib/XpmCrDataFrP.c
lib/XpmCrIFrBuf.c
lib/XpmCrIFrData.c
lib/XpmCrPFrBuf.c
lib/XpmCrPFrData.c
lib/XpmRdFToData.c
lib/XpmRdFToI.c
lib/XpmRdFToP.c
lib/XpmWrFFrData.c
lib/XpmWrFFrI.c
lib/XpmWrFFrP.c
lib/create.c
lib/data.c
lib/hashtable.c
lib/misc.c
lib/parse.c
lib/rgb.c
lib/rgbtab.h
lib/scan.c
lib/simx.h
lib/simx.c
lib/xpm.h
lib/xpmP.h
doc
doc/xpm.ps
sxpm
sxpm/Imakefile
sxpm/Makefile.noXtree
sxpm/plaid.xpm
sxpm/plaid_ext.xpm
sxpm/plaid_mask.xpm
sxpm/sxpm.c
sxpm/sxpm.man
+224
View File
@@ -0,0 +1,224 @@
/*
* Copyright (C) 1989-94 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.
*/
/*****************************************************************************\
* hashtable.c: *
* *
* XPM library *
* *
* Developed by Arnaud Le Hors *
* this originaly comes from Colas Nahaboo as a part of Wool *
* *
\*****************************************************************************/
#include "xpm34p.h"
LFUNC(AtomMake, xpmHashAtom, (char *name, void *data));
LFUNC(HashTableGrows, int, (xpmHashTable * table));
static xpmHashAtom
AtomMake(char *name, void *data) /* makes an atom */
/* char *name; */ /* WARNING: is just pointed to */
/* void *data; */
{
xpmHashAtom object = (xpmHashAtom) XpmMalloc(sizeof(struct _xpmHashAtom));
if (object) {
object->name = name;
object->data = data;
}
return object;
}
/************************\
* *
* hash table routines *
* *
\************************/
/*
* Hash function definition:
* HASH_FUNCTION: hash function, hash = hashcode, hp = pointer on char,
* hash2 = temporary for hashcode.
* INITIAL_TABLE_SIZE in slots
* HASH_TABLE_GROWS how hash table grows.
*/
/* Mock lisp function */
#define HASH_FUNCTION hash = (hash << 5) - hash + *hp++;
/* #define INITIAL_HASH_SIZE 2017 */
#define INITIAL_HASH_SIZE 256 /* should be enough for colors */
#define HASH_TABLE_GROWS size = size * 2;
/* aho-sethi-ullman's HPJ (sizes should be primes)*/
#ifdef notdef
#define HASH_FUNCTION hash <<= 4; hash += *hp++; \
if(hash2 = hash & 0xf0000000) hash ^= (hash2 >> 24) ^ hash2;
#define INITIAL_HASH_SIZE 4095 /* should be 2^n - 1 */
#define HASH_TABLE_GROWS size = size << 1 + 1;
#endif
/* GNU emacs function */
/*
#define HASH_FUNCTION hash = (hash << 3) + (hash >> 28) + *hp++;
#define INITIAL_HASH_SIZE 2017
#define HASH_TABLE_GROWS size = size * 2;
*/
/* end of hash functions */
/*
* The hash table is used to store atoms via their NAME:
*
* NAME --hash--> ATOM |--name--> "foo"
* |--data--> any value which has to be stored
*
*/
/*
* xpmHashSlot gives the slot (pointer to xpmHashAtom) of a name
* (slot points to NULL if it is not defined)
*
*/
xpmHashAtom *
xpmHashSlot(xpmHashTable *table, char *s)
{
xpmHashAtom *atomTable = table->atomTable;
unsigned int hash;
xpmHashAtom *p;
char *hp = s;
char *ns;
hash = 0;
while (*hp) { /* computes hash function */
HASH_FUNCTION
}
p = atomTable + hash % table->size;
while (*p) {
ns = (*p)->name;
if (ns[0] == s[0] && strcmp(ns, s) == 0)
break;
p--;
if (p < atomTable)
p = atomTable + table->size - 1;
}
return p;
}
static int
HashTableGrows(xpmHashTable *table)
{
xpmHashAtom *atomTable = table->atomTable;
int size = table->size;
xpmHashAtom *t, *p;
int i;
int oldSize = size;
t = atomTable;
HASH_TABLE_GROWS
table->size = size;
table->limit = size / 3;
atomTable = (xpmHashAtom *) XpmMalloc(size * sizeof(*atomTable));
if (!atomTable)
return (XpmNoMemory);
table->atomTable = atomTable;
for (p = atomTable + size; p > atomTable;)
*--p = NULL;
for (i = 0, p = t; i < oldSize; i++, p++)
if (*p) {
xpmHashAtom *ps = xpmHashSlot(table, (*p)->name);
*ps = *p;
}
XpmFree(t);
return (XpmSuccess);
}
/*
* xpmHashIntern(table, name, data)
* an xpmHashAtom is created if name doesn't exist, with the given data.
*/
int
xpmHashIntern(xpmHashTable *table, char *tag, void *data)
{
xpmHashAtom *slot;
if (!*(slot = xpmHashSlot(table, tag))) {
/* undefined, make a new atom with the given data */
if (!(*slot = AtomMake(tag, data)))
return (XpmNoMemory);
if (table->used >= table->limit) {
int ErrorStatus;
if ((ErrorStatus = HashTableGrows(table)) != XpmSuccess)
return (ErrorStatus);
table->used++;
return (XpmSuccess);
}
table->used++;
}
return (XpmSuccess);
}
/*
* must be called before allocating any atom
*/
int
xpmHashTableInit(xpmHashTable *table)
{
xpmHashAtom *p;
xpmHashAtom *atomTable;
table->size = INITIAL_HASH_SIZE;
table->limit = table->size / 3;
table->used = 0;
atomTable = (xpmHashAtom *) XpmMalloc(table->size * sizeof(*atomTable));
if (!atomTable)
return (XpmNoMemory);
for (p = atomTable + table->size; p > atomTable;)
*--p = NULL;
table->atomTable = atomTable;
return (XpmSuccess);
}
/*
* frees a hashtable and all the stored atoms
*/
void
xpmHashTableFree(xpmHashTable *table)
{
xpmHashAtom *p;
xpmHashAtom *atomTable = table->atomTable;
for (p = atomTable + table->size; p > atomTable;)
if (*--p)
XpmFree(*p);
XpmFree(atomTable);
table->atomTable = NULL;
}
+572
View File
File diff suppressed because it is too large Load Diff
+704
View File
File diff suppressed because it is too large Load Diff
+63
View File
@@ -0,0 +1,63 @@
/*
* Copyright (C) 1989-94 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.
*/
/*****************************************************************************\
* XpmRdFToData.c: *
* *
* XPM library *
* Parse an XPM file and create an array of strings corresponding to it. *
* *
* Developed by Dan Greening dgreen@cs.ucla.edu / dgreen@sti.com *
\*****************************************************************************/
#include "xpm34p.h"
int
XpmReadFileToData(char *filename, char ***data_return)
{
XpmImage image;
XpmInfo info;
int ErrorStatus;
info.valuemask = XpmReturnComments | XpmReturnExtensions;
/*
* initialize return value
*/
if (data_return)
*data_return = NULL;
ErrorStatus = XpmReadFileToXpmImage(filename, &image, &info);
if (ErrorStatus != XpmSuccess)
return (ErrorStatus);
ErrorStatus =
XpmCreateDataFromXpmImage(data_return, &image, &info);
XpmFreeXpmImage(&image);
XpmFreeXpmInfo(&info);
return (ErrorStatus);
}
+91
View File
@@ -0,0 +1,91 @@
/*
* Copyright (C) 1989-94 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.
*/
/*****************************************************************************\
* XpmRdFToI.c: *
* *
* XPM library *
* Parse an XPM file and create the image and possibly its mask *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#include "xpm34p.h"
int
XpmReadFileToImage(Display *display, char *filename,
XImage **image_return, XImage **shapeimage_return, XpmAttributes *attributes)
{
XpmImage image;
XpmInfo info;
int ErrorStatus;
/* create an XpmImage from the file */
if (attributes) {
xpmInitAttributes(attributes);
xpmSetInfoMask(&info, attributes);
ErrorStatus = XpmReadFileToXpmImage(filename, &image, &info);
} else
ErrorStatus = XpmReadFileToXpmImage(filename, &image, NULL);
if (ErrorStatus != XpmSuccess)
return (ErrorStatus);
/* create the related ximages */
ErrorStatus = XpmCreateImageFromXpmImage(display, &image,
image_return, shapeimage_return,
attributes);
if (attributes) {
if (ErrorStatus >= 0) /* no fatal error */
xpmSetAttributes(attributes, &image, &info);
XpmFreeXpmInfo(&info);
}
/* free the XpmImage */
XpmFreeXpmImage(&image);
return (ErrorStatus);
}
int
XpmReadFileToXpmImage(char *filename, XpmImage *image, XpmInfo *info)
{
xpmData mdata;
int ErrorStatus;
/* init returned values */
xpmInitXpmImage(image);
xpmInitXpmInfo(info);
/* open file to read */
if ((ErrorStatus = xpmReadFile(filename, &mdata)) != XpmSuccess)
return (ErrorStatus);
/* create the XpmImage from the XpmData */
ErrorStatus = xpmParseData(&mdata, image, info);
xpmDataClose(&mdata);
return (ErrorStatus);
}
+72
View File
@@ -0,0 +1,72 @@
/*
* Copyright (C) 1989-94 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.
*/
/*****************************************************************************\
* XpmRdFToP.c: *
* *
* XPM library *
* Parse an XPM file and create the pixmap and possibly its mask *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#ifndef FOR_MSW
#include "xpm34p.h"
int
XpmReadFileToPixmap(Display *display, Drawable d, char *filename, Pixmap *pixmap_return,
Pixmap *shapemask_return, XpmAttributes *attributes)
{
XImage *ximage, *shapeimage;
int ErrorStatus;
/* initialize return values */
if (pixmap_return)
*pixmap_return = 0;
if (shapemask_return)
*shapemask_return = 0;
/* create the images */
ErrorStatus = XpmReadFileToImage(display, filename,
(pixmap_return ? &ximage : NULL),
(shapemask_return ? &shapeimage : NULL),
attributes);
if (ErrorStatus < 0) /* fatal error */
return (ErrorStatus);
/* create the pixmaps and destroy images */
if (pixmap_return && ximage) {
xpmCreatePixmapFromImage(display, d, ximage, pixmap_return);
XDestroyImage(ximage);
}
if (shapemask_return && shapeimage) {
xpmCreatePixmapFromImage(display, d, shapeimage, shapemask_return);
XDestroyImage(shapeimage);
}
return (ErrorStatus);
}
#endif
+192
View File
@@ -0,0 +1,192 @@
/*
* Copyright (C) 1989-94 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.
*/
XPM Version 3
WHAT IS XPM?
============
XPM (X PixMap) is a format for storing/retrieving X pixmaps to/from files.
Here is provided a library containing a set of four functions, similar to the
X bitmap functions as defined in the Xlib: XpmCreatePixmapFromData,
XpmCreateDataFromPixmap, XpmReadFileToPixmap and XpmWriteFileFromPixmap for
respectively including, storing, reading and writing this format, plus four
other: XpmCreateImageFromData, XpmCreateDataFromImage, XpmReadFileToImage and
XpmWriteFileFromImage for working with images instead of pixmaps.
This new version provides a C includable format, defaults for different types
of display: monochrome/color/grayscale, hotspot coordinates and symbol names
for colors for overriding default colors when creating the pixmap. It provides
a mechanism for storing information while reading a file which is re-used
while writing. This way comments, default colors and symbol names aren't lost.
It also handles "transparent pixels" by returning a shape mask in addition to
the created pixmap.
See the XPM Manual for more details.
HOW TO GET XPM?
===============
New xpm updates are announced on the comp.windows.x newsgroup, and on the
"xpm-talk" list. All new "official" xpm releases can be found by ftp on:
ftp.x.org (18.112.44.100) contrib (Boston, USA)
avahi.inria.fr (192.5.60.47) pub (Sophia Antipolis, France)
DOCUMENTATION:
=============
Old users might read the CHANGES file for a history of changes interesting
the user.
Read the doc. The documentation is in PostScript format (file doc/xpm.ps) and
has been produced with FrameMaker. The source files are available on request.
INSTALLATION:
============
To obtain the XPM library, first uncompress and untar the compressed tar file
in an approriate directory.
Then you can either compile xpm via "imake" or in a stand-alone way.
WITH IMAKE:
Imakefiles are provided to build both shared and unshared libraries.
First have a look at the beginning of the lib/Imakefile and see if you
need to do some modification to fit with your system.
You should know how to use imake to build the XPM Makefiles
by executing "xmkmf", then do:
make Makefiles
make depend (if you want to)
make
which will build the XPM library and the sxpm application.
Then do:
make install
make install.man
which will install the library and the sxpm pregram and man page.
If it fails, you may edit the Imakefiles to add compilation flags to
suit your machine.
WITHOUT IMAKE:
To compile xpm, in the xpm directory you just created, do:
make -f Makefile.noXtree
Then to install it, do:
make -f Makefile.noXtree install
SXPM:
====
In addition to the library the sxpm tool is provided to show XPM file and
convert them from XPM1 or XPM2 to XPM version 3. If you have previously done
'make' or 'make all' you should have it yet, otherwise just do:
cd sxpm; make
This application shows you most of the features of XPM and its source can be
used to quickly see how to use the provided functions.
By executing 'sxpm -help' you will get the usage.
Executing 'sxpm -plaid' will show a demo of the XpmCreatePixmapFromData
function. The pixmap is created from the static variable plaid defined in the
sxpm.c file. sxpm will end when you press the key 'q' in the created window.
Executing 'sxpm -plaid -sc lines_in_mix blue' will show the feature of
overriding color symbols giving a colorname, executing 'sxpm -sp lines_in_mix
1' will show overriding giving a pixel value, and executing 'sxpm -plaid -cp
red 0' will show overriding giving a color value.
Then you should try 'sxpm -plaid -o output' to get an output file using the
XpmWriteFileFromPixmap function.
You can now try 'sxpm -plaid -o - -nod -rgb /usr/lib/X11/rgb.txt' to directly
get the pixmap printed out on the standard output with colornames instead of
rgb values.
Then you should try 'sxpm plaid.xpm' to use the XpmReadFileToPixmap function,
and 'cat plaid_mask.xpm|sxpm' to see how "transparent pixels" are handled.
The XpmCreatePixmapFromData function is on purpose called without any XpmInfos
flag to show the utility of this one. Indeed, compare the color section of the
two files foo and bar obtained from 'sxpm -nod -plaid -o foo' and 'sxpm -nod
plaid.xpm -o bar'. All the default colors and also the comments have been
restored.
To end look at plaid_ext.xpm and try "sxpm -nod plaid_ext.xpm -v" to see how
extensions are handled.
Of course, other combinations are allowed and should be tried. Thus, 'sxpm
plaid.xpm -o output -nod' will show you how to convert a file from XPM1 or XPM2
to a XPM version 3 using sxpm.
See the manual page for more detail.
OTHER TOOLS:
===========
Several converters dealing with XPM and a pixmap editor can be found in the
xpm-contrib distribution. Also I recommend the use of netpbm to do any kind of
general image operations such as scaling, resizing, dithering, and to convert
from and to any other image format.
DISCUSSION:
==========
There is a mailing list to discuss about XPM which is xpm-talk@sophia.inria.fr.
Any request to subscribe should be sent to xpm-talk-request@sophia.inria.fr.
COPYRIGHT:
==========
Copyright 1989-94 GROUPE BULL --
See license conditions in the COPYRIGHT file of the XPM distribution
Please mail any bug reports or modifications done, comments, suggestions,
requests for updates or patches to port on another machine to:
lehors@sophia.inria.fr (INTERNET)
33 (FRANCE) 93.65.77.71 (VOICE PHONE)
Arnaud Le Hors (SURFACE MAIL)
Bull c/o Inria BP. 109
2004, Route des lucioles
Sophia Antipolis
06561 Valbonne Cedex
FRANCE
+83
View File
@@ -0,0 +1,83 @@
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.
!!!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!
--
////|\\\\ \\\\\\ 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
+282
View File
@@ -0,0 +1,282 @@
/*
* Copyright (C) 1989-94 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.
*/
/*****************************************************************************\
* rgb.c: *
* *
* XPM library *
* Rgb file utilities *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
/*
* 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
*/
#include "xpm34p.h"
#ifdef VMS
#include "sys$library:ctype.h"
#include "sys$library:string.h"
#else
#include <ctype.h>
#if defined(SYSV) || defined(SVR4)
#include <string.h>
#else
#include <strings.h>
#endif
#endif
#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
* number of entries stored.
*/
int
xpmReadRgbNames(char *rgb_fname, xpmRgbName rgbn[])
{
FILE *rgbf;
int i, items, red, green, blue;
char line[512], name[512], *rgbname, *n, *m;
xpmRgbName *rgb;
/* Open the rgb text file. Abort if error. */
if ((rgbf = fopen(rgb_fname, "r")) == NULL)
return 0;
/* Loop reading each line in the file. */
for (i = 0, rgb = rgbn; fgets(line, sizeof(line), rgbf); i++, rgb++) {
/* Quit if rgb text file is too large. */
if (i == MAX_RGBNAMES) {
/* Too many entries in rgb text file, give up here */
break;
}
/* Read the line. Skip silently if bad. */
items = sscanf(line, "%d %d %d %[^\n]\n", &red, &green, &blue, name);
if (items != 4) {
i--;
continue;
}
/*
* Make sure rgb values are within 0->255 range. Skip silently if
* bad.
*/
if (red < 0 || red > 0xFF ||
green < 0 || green > 0xFF ||
blue < 0 || blue > 0xFF) {
i--;
continue;
}
/* Allocate memory for ascii name. If error give up here. */
if (!(rgbname = (char *) XpmMalloc(strlen(name) + 1)))
break;
/* Copy string to ascii name and lowercase it. */
for (n = name, m = rgbname; *n; n++)
*m++ = tolower(*n);
*m = '\0';
/* Save the rgb values and ascii name in the array. */
rgb->r = red * 257; /* 65535/255 = 257 */
rgb->g = green * 257;
rgb->b = blue * 257;
rgb->name = rgbname;
}
fclose(rgbf);
/* Return the number of read rgb names. */
return i < 0 ? 0 : i;
}
/*
* Return the color name corresponding to the given rgb values
*/
char *
xpmGetRgbName(xpmRgbName rgbn[], int rgbn_max, int red, int green, int blue)
/* xpmRgbName rgbn[]; */ /* rgb mnemonics from rgb text file */
/* int rgbn_max; */ /* number of rgb mnemonics in table */
/* int red, green, blue; */ /* rgb values */
{
int i;
xpmRgbName *rgb;
/*
* Just perform a dumb linear search over the rgb values of the color
* mnemonics. One could speed things up by sorting the rgb values and
* using a binary search, or building a hash table, etc...
*/
for (i = 0, rgb = rgbn; i < rgbn_max; i++, rgb++)
if (red == rgb->r && green == rgb->g && blue == rgb->b)
return rgb->name;
/* if not found return NULL */
return NULL;
}
/*
* Free the strings which have been malloc'ed in xpmReadRgbNames
*/
void
xpmFreeRgbNames(xpmRgbName rgbn[], int rgbn_max)
{
int i;
xpmRgbName *rgb;
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(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[], int rgbn_max, int red, int green, int blue)
/* xpmRgbName rgbn[]; */ /* rgb mnemonics from rgb text file
* not used */
/* int rgbn_max; */ /* not used */
/* int red, green, blue; */ /* rgb values */
{
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 = strdup(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 = strcasecmp(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 */
+292
View File
@@ -0,0 +1,292 @@
/*
* Copyright (C) 1989-94 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 substitue 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;
+843
View File
File diff suppressed because it is too large Load Diff
+284
View File
@@ -0,0 +1,284 @@
/*
* Copyright (C) 1989-94 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) *
\*****************************************************************************/
#include "xpm34.h"
#ifdef FOR_MSW
#include "xpm34p.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(char 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) {
/* *img = CreateCompatibleBitmap(*d, width, height); */
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
+142
View File
@@ -0,0 +1,142 @@
/*
* Copyright (C) 1989-94 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 */
/*
* 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 */
#ifndef True
#define True 1
#define False 0
#endif
/*
#ifndef Bool
typedef BOOL Bool;
#endif
*/
/* make these local here, simx.c gets the same from xpm.h */
#undef LFUNC
#undef FUNC
#endif /* def FOR_MSW */
#endif /* _SIMX_H */
+58
View File
@@ -0,0 +1,58 @@
/*
* Copyright (C) 1989-94 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.
*/
/*****************************************************************************\
* XpmWrFFrData.c: *
* *
* XPM library *
* Parse an Xpm array and write a file that corresponds to it. *
* *
* Developed by Dan Greening dgreen@cs.ucla.edu / dgreen@sti.com *
\*****************************************************************************/
#include "xpm34.h"
#include "xpm34p.h"
int
XpmWriteFileFromData(char *filename, char **data)
{
XpmImage image;
XpmInfo info;
int ErrorStatus;
info.valuemask = XpmReturnComments | XpmReturnExtensions;
ErrorStatus = XpmCreateXpmImageFromData(data, &image, &info);
if (ErrorStatus != XpmSuccess)
return (ErrorStatus);
ErrorStatus = XpmWriteFileFromXpmImage(filename, &image, &info);
XpmFreeXpmImage(&image);
XpmFreeXpmInfo(&info);
return (ErrorStatus);
}
+258
View File
@@ -0,0 +1,258 @@
/*
* Copyright (C) 1989-94 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.
*/
/*****************************************************************************\
* XpmWrFFrI.c: *
* *
* XPM library *
* Write an image and possibly its mask to an XPM file *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#include "xpm34p.h"
#ifdef FOR_MSW
#include "ctype.h"
#endif
#include <string.h>
LFUNC(WriteColors, void, (FILE *file, XpmColor *colors, unsigned int ncolors));
LFUNC(WritePixels, int, (FILE *file, unsigned int width, unsigned int height,
unsigned int cpp, unsigned int *pixels,
XpmColor *colors));
LFUNC(WriteExtensions, void, (FILE *file, XpmExtension *ext,
unsigned int num));
int
XpmWriteFileFromImage(Display *display, char *filename, XImage *image, XImage *shapeimage, XpmAttributes *attributes)
{
XpmImage xpmimage;
XpmInfo info;
int ErrorStatus;
/* create an XpmImage from the image */
ErrorStatus = XpmCreateXpmImageFromImage(display, image, shapeimage,
&xpmimage, attributes);
if (ErrorStatus != XpmSuccess)
return (ErrorStatus);
/* write the file from the XpmImage */
if (attributes) {
xpmSetInfo(&info, attributes);
ErrorStatus = XpmWriteFileFromXpmImage(filename, &xpmimage, &info);
} else
ErrorStatus = XpmWriteFileFromXpmImage(filename, &xpmimage, NULL);
/* free the XpmImage */
XpmFreeXpmImage(&xpmimage);
return (ErrorStatus);
}
int
XpmWriteFileFromXpmImage(char *filename, XpmImage *image, XpmInfo *info)
{
xpmData mdata;
char *name, *dot, *s, new_name[BUFSIZ];
int ErrorStatus;
int len, i;
/* open file to write */
if ((ErrorStatus = xpmWriteFile(filename, &mdata)) != XpmSuccess)
return (ErrorStatus);
/* figure out a name */
if (filename) {
#ifdef VMS
name = filename;
#else
#ifdef FOR_MSW
if (!(name = strchr(filename, '\\')))
#else
if (!(name = strchr(filename, '/')))
#endif
name = filename;
else
name++;
#endif
if (dot = strchr(name, '.')) {
strcpy(new_name, name);
#ifdef FOR_MSW
// Convert to lower case
len = strlen(new_name);
for (i = 0; i < len; i++)
new_name[i] = tolower(new_name[i]);
#endif
/* change '.' to '_' to get a valid C syntax name */
name = s = new_name;
while (dot = strchr(s, '.')) {
*dot = '_';
s = dot;
}
}
} else
name = "image_name";
/* write the XpmData from the XpmImage */
if (ErrorStatus == XpmSuccess)
ErrorStatus = xpmWriteData(&mdata, image, name, info);
xpmDataClose(&mdata);
return (ErrorStatus);
}
int
xpmWriteData(xpmData *mdata, XpmImage *image, char *name, XpmInfo *info)
{
/* calculation variables */
unsigned int cmts, extensions;
FILE *file;
int ErrorStatus;
/* store this to speed up */
file = mdata->stream.file;
cmts = info && (info->valuemask & XpmComments);
extensions = info && (info->valuemask & XpmExtensions)
&& info->nextensions;
/* print the header line */
fprintf(file, "/* XPM */\nstatic char * %s[] = {\n", name);
/* print the hints line */
if (cmts && info->hints_cmt)
fprintf(file, "/*%s*/\n", info->hints_cmt);
fprintf(file, "\"%d %d %d %d", image->width, image->height,
image->ncolors, image->cpp);
if (info && (info->valuemask & XpmHotspot))
fprintf(file, " %d %d", info->x_hotspot, info->y_hotspot);
if (extensions)
fprintf(file, " XPMEXT");
fprintf(file, "\",\n");
/* print colors */
if (cmts && info->colors_cmt)
fprintf(file, "/*%s*/\n", info->colors_cmt);
WriteColors(file, image->colorTable, image->ncolors);
/* print pixels */
if (cmts && info->pixels_cmt)
fprintf(file, "/*%s*/\n", info->pixels_cmt);
ErrorStatus = WritePixels(file, image->width, image->height, image->cpp,
image->data, image->colorTable);
if (ErrorStatus != XpmSuccess)
return (ErrorStatus);
/* print extensions */
if (extensions)
WriteExtensions(file, info->extensions, info->nextensions);
/* close the array */
fprintf(file, "};\n");
return (XpmSuccess);
}
static void
WriteColors(FILE *file, XpmColor *colors, unsigned int ncolors)
{
unsigned int a, key;
char *s;
char **defaults;
for (a = 0; a < ncolors; a++, colors++) {
defaults = (char **) colors;
fprintf(file, "\"%s", *defaults++);
for (key = 1; key <= NKEYS; key++, defaults++) {
if (s = *defaults)
fprintf(file, "\t%s %s", xpmColorKeys[key - 1], s);
}
fprintf(file, "\",\n");
}
}
static int
WritePixels(FILE *file, unsigned int width, unsigned int height, unsigned int cpp, unsigned int *pixels, XpmColor *colors)
{
char *s, *p, *buf;
unsigned int x, y, h;
h = height - 1;
p = buf = (char *) XpmMalloc(width * cpp + 3);
if (!buf)
return (XpmNoMemory);
*buf = '"';
p++;
for (y = 0; y < h; y++) {
s = p;
for (x = 0; x < width; x++, pixels++) {
strncpy(s, colors[*pixels].string, cpp);
s += cpp;
}
*s++ = '"';
*s = '\0';
fprintf(file, "%s,\n", buf);
}
/* duplicate some code to avoid a test in the loop */
s = p;
for (x = 0; x < width; x++, pixels++) {
strncpy(s, colors[*pixels].string, cpp);
s += cpp;
}
*s++ = '"';
*s = '\0';
fprintf(file, "%s", buf);
XpmFree(buf);
return (XpmSuccess);
}
static void
WriteExtensions(FILE *file, XpmExtension *ext, unsigned int num)
{
unsigned int x, y, n;
char **line;
for (x = 0; x < num; x++, ext++) {
fprintf(file, ",\n\"XPMEXT %s\"", ext->name);
n = ext->nlines;
for (y = 0, line = ext->lines; y < n; y++, line++)
fprintf(file, ",\n\"%s\"", *line);
}
fprintf(file, ",\n\"XPMENDEXT\"");
}
+83
View File
@@ -0,0 +1,83 @@
/*
* Copyright (C) 1989-94 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.
*/
#include "xpm34.h"
#ifndef FOR_MSW
/*****************************************************************************\
* XpmWrFFrP.c: *
* *
* XPM library *
* Write a pixmap and possibly its mask to an XPM file *
* *
* Developed by Arnaud Le Hors *
\*****************************************************************************/
#include "xpm34p.h"
#ifdef VMS
#include "sys$library:string.h"
#else
#if defined(SYSV) || defined(SVR4)
#include <string.h>
#else
#include <strings.h>
#endif
#endif
int
XpmWriteFileFromPixmap(Display *display, char *filename, Pixmap pixmap, Pixmap shapemask, XpmAttributes *attributes)
{
XImage *ximage = NULL;
XImage *shapeimage = NULL;
unsigned int width = 0;
unsigned int height = 0;
int ErrorStatus;
/* get geometry */
if (attributes && attributes->valuemask & XpmSize) {
width = attributes->width;
height = attributes->height;
}
/* get the ximages */
if (pixmap)
xpmCreateImageFromPixmap(display, pixmap, &ximage, &width, &height);
if (shapemask)
xpmCreateImageFromPixmap(display, shapemask, &shapeimage,
&width, &height);
/* write to the file */
ErrorStatus = XpmWriteFileFromImage(display, filename, ximage, shapeimage,
attributes);
/* destroy the ximages */
if (ximage)
XDestroyImage(ximage);
if (shapeimage)
XDestroyImage(shapeimage);
return (ErrorStatus);
}
#endif
+555
View File
File diff suppressed because it is too large Load Diff
+304
View File
@@ -0,0 +1,304 @@
/*
* Copyright (C) 1989-94 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.
*/
/*****************************************************************************\
* xpmP.h: *
* *
* XPM library *
* Private Include file *
* *
* 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 XPMP_h
#define XPMP_h
#include "xpm34.h"
/*
* lets try to solve include files
*/
#ifdef VMS
#include "sys$library:stdio.h"
#include "sys$library:string.h"
#else /* VMS */
#include <stdio.h>
/* stdio.h doesn't declare popen on a Sequent DYNIX OS */
#ifdef sequent
extern FILE *popen();
#endif
#if defined(SYSV) || defined(SVR4)
#include <string.h>
#ifndef index
#define index strchr
#endif
#ifndef rindex
#define rindex strrchr
#endif
#else /* defined(SYSV) || defined(SVR4) */
#include <strings.h>
#endif
#endif /* VMS */
#if (defined(SYSV) || defined(SVR4) || defined(VMS)) && !defined(__sgi)
#define bcopy(source, dest, count) memcpy(dest, source, count)
#define bzero(b, len) memset(b, 0, len)
#endif
/* the following should help people wanting to use their own functions */
#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
typedef struct {
unsigned int type;
union {
FILE *file;
char **data;
} stream;
char *cptr;
unsigned int line;
int CommentLength;
char Comment[BUFSIZ];
char *Bcmt, *Ecmt, Bos, Eos;
int format; /* 1 if XPM1, 0 otherwise */
} xpmData;
#define XPMARRAY 0
#define XPMFILE 1
#define XPMPIPE 2
#define XPMBUFFER 3
#define EOL '\n'
#define TAB '\t'
#define SPC ' '
typedef struct {
char *type; /* key word */
char *Bcmt; /* string beginning comments */
char *Ecmt; /* string ending comments */
char Bos; /* character beginning strings */
char Eos; /* character ending strings */
char *Strs; /* strings separator */
char *Dec; /* data declaration string */
char *Boa; /* string beginning assignment */
char *Eoa; /* string ending assignment */
} xpmDataType;
extern xpmDataType xpmDataTypes[];
/*
* rgb values and ascii names (from rgb text file) rgb values,
* range of 0 -> 65535 color mnemonic of rgb value
*/
typedef struct {
int r, g, b;
char *name;
} xpmRgbName;
/* Maximum number of rgb mnemonics allowed in rgb text file. */
#define MAX_RGBNAMES 1024
extern char *xpmColorKeys[];
#define TRANSPARENT_COLOR "None" /* this must be a string! */
/* number of xpmColorKeys */
#define NKEYS 5
/* XPM private routines */
FUNC(xpmWriteData, int, (xpmData *mdata, XpmImage *image, char *name,
XpmInfo *info));
FUNC(xpmParseData, int, (xpmData *data, XpmImage *image, XpmInfo *info));
FUNC(xpmFreeColorTable, void, (XpmColor *colorTable, int ncolors));
FUNC(xpmInitAttributes, void, (XpmAttributes *attributes));
FUNC(xpmInitXpmImage, void, (XpmImage *image));
FUNC(xpmInitXpmInfo, void, (XpmInfo *info));
FUNC(xpmSetInfoMask, void, (XpmInfo *info, XpmAttributes *attributes));
FUNC(xpmSetInfo, void, (XpmInfo *info, XpmAttributes *attributes));
FUNC(xpmSetAttributes, void, (XpmAttributes *attributes, XpmImage *image,
XpmInfo *info));
#ifndef FOR_MSW
FUNC(xpmCreatePixmapFromImage, void, (Display *display, Drawable d,
XImage *ximage, Pixmap *pixmap_return));
FUNC(xpmCreateImageFromPixmap, void, (Display *display, Pixmap pixmap,
XImage **ximage_return,
unsigned int *width,
unsigned int *height));
#endif
/* I/O utility */
FUNC(xpmNextString, int, (xpmData *mdata));
FUNC(xpmNextUI, int, (xpmData *mdata, unsigned int *ui_return));
FUNC(xpmGetString, int, (xpmData *mdata, char **sptr, unsigned int *l));
#define xpmGetC(mdata) \
((!mdata->type || mdata->type == XPMBUFFER) ? \
(*mdata->cptr++) : (getc(mdata->stream.file)))
FUNC(xpmNextWord, unsigned int,
(xpmData *mdata, char *buf, unsigned int buflen));
FUNC(xpmGetCmt, int, (xpmData *mdata, char **cmt));
FUNC(xpmReadFile, int, (char *filename, xpmData *mdata));
FUNC(xpmWriteFile, int, (char *filename, xpmData *mdata));
FUNC(xpmOpenArray, void, (char **data, xpmData *mdata));
FUNC(xpmDataClose, int, (xpmData *mdata));
FUNC(xpmParseHeader, int, (xpmData *mdata));
FUNC(xpmOpenBuffer, void, (char *buffer, xpmData *mdata));
/* RGB utility */
FUNC(xpmReadRgbNames, int, (char *rgb_fname, xpmRgbName *rgbn));
FUNC(xpmGetRgbName, char *, (xpmRgbName *rgbn, int rgbn_max,
int red, int green, int blue));
FUNC(xpmFreeRgbNames, void, (xpmRgbName *rgbn, int rgbn_max));
#ifdef FOR_MSW
FUNC(xpmGetRGBfromName,int, (char *name, int *r, int *g, int *b));
#endif
FUNC(xpm_xynormalizeimagebits, void, (register unsigned char *bp,
register XImage *img));
FUNC(xpm_znormalizeimagebits, void, (register unsigned char *bp,
register XImage *img));
/*
* Macros
*
* The XYNORMALIZE macro determines whether XY format data requires
* normalization and calls a routine to do so if needed. The logic in
* this module is designed for LSBFirst byte and bit order, so
* normalization is done as required to present the data in this order.
*
* The ZNORMALIZE macro performs byte and nibble order normalization if
* required for Z format data.
*
* The XYINDEX macro computes the index to the starting byte (char) boundary
* for a bitmap_unit containing a pixel with coordinates x and y for image
* data in XY format.
*
* The ZINDEX* macros compute the index to the starting byte (char) boundary
* for a pixel with coordinates x and y for image data in ZPixmap format.
*
*/
#define XYNORMALIZE(bp, img) \
if ((img->byte_order == MSBFirst) || (img->bitmap_bit_order == MSBFirst)) \
xpm_xynormalizeimagebits((unsigned char *)(bp), img)
#define ZNORMALIZE(bp, img) \
if (img->byte_order == MSBFirst) \
xpm_znormalizeimagebits((unsigned char *)(bp), img)
#define XYINDEX(x, y, img) \
((y) * img->bytes_per_line) + \
(((x) + img->xoffset) / img->bitmap_unit) * (img->bitmap_unit >> 3)
#define ZINDEX(x, y, img) ((y) * img->bytes_per_line) + \
(((x) * img->bits_per_pixel) >> 3)
#define ZINDEX32(x, y, img) ((y) * img->bytes_per_line) + ((x) << 2)
#define ZINDEX16(x, y, img) ((y) * img->bytes_per_line) + ((x) << 1)
#define ZINDEX8(x, y, img) ((y) * img->bytes_per_line) + (x)
#define ZINDEX1(x, y, img) ((y) * img->bytes_per_line) + ((x) >> 3)
#if __STDC__
#define Const const
#else
#define Const /**/
#endif
/*
* there are structures and functions related to hastable code
*/
typedef struct _xpmHashAtom {
char *name;
void *data;
} *xpmHashAtom;
typedef struct {
int size;
int limit;
int used;
xpmHashAtom *atomTable;
} xpmHashTable;
FUNC(xpmHashTableInit, int, (xpmHashTable *table));
FUNC(xpmHashTableFree, void, (xpmHashTable *table));
FUNC(xpmHashSlot, xpmHashAtom *, (xpmHashTable *table, char *s));
FUNC(xpmHashIntern, int, (xpmHashTable *table, char *tag, void *data));
#define HashAtomData(i) ((void *)i)
#define HashColorIndex(slot) ((unsigned int)((*slot)->data))
#define USE_HASHTABLE (cpp > 2 && ncolors > 4)
#ifdef NEED_STRDUP
FUNC(strdup, char *, (char *s1));
#endif
#ifdef NEED_STRCASECMP
FUNC(strcasecmp, int, (char *s1, char *s2));
#endif
FUNC(atoui, unsigned int, (char *p, unsigned int l, unsigned int *ui_return));
#endif