Updated lib to 3.4g
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5782 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -70,12 +70,15 @@ $(CPPFLAGS) /Fo$@ /Tp $<
|
|||||||
<<
|
<<
|
||||||
|
|
||||||
OBJECTS = \
|
OBJECTS = \
|
||||||
|
..\xpm\$D\attrib.obj \
|
||||||
..\xpm\$D\crbuffri.obj \
|
..\xpm\$D\crbuffri.obj \
|
||||||
..\xpm\$D\crdatfri.obj \
|
..\xpm\$D\crdatfri.obj \
|
||||||
..\xpm\$D\create.obj \
|
..\xpm\$D\create.obj \
|
||||||
..\xpm\$D\crifrbuf.obj \
|
..\xpm\$D\crifrbuf.obj \
|
||||||
..\xpm\$D\crifrdat.obj \
|
..\xpm\$D\crifrdat.obj \
|
||||||
..\xpm\$D\data.obj \
|
..\xpm\$D\data.obj \
|
||||||
|
..\xpm\$D\image.obj \
|
||||||
|
..\xpm\$D\info.obj \
|
||||||
..\xpm\$D\hashtab.obj \
|
..\xpm\$D\hashtab.obj \
|
||||||
..\xpm\$D\misc.obj \
|
..\xpm\$D\misc.obj \
|
||||||
..\xpm\$D\parse.obj \
|
..\xpm\$D\parse.obj \
|
||||||
@@ -85,7 +88,6 @@ OBJECTS = \
|
|||||||
..\xpm\$D\scan.obj \
|
..\xpm\$D\scan.obj \
|
||||||
..\xpm\$D\simx.obj \
|
..\xpm\$D\simx.obj \
|
||||||
..\xpm\$D\wrffrdat.obj \
|
..\xpm\$D\wrffrdat.obj \
|
||||||
..\xpm\$D\wrffrp.obj \
|
|
||||||
..\xpm\$D\wrffri.obj
|
..\xpm\$D\wrffri.obj
|
||||||
|
|
||||||
all: $(OS2XPMLIB)
|
all: $(OS2XPMLIB)
|
||||||
|
302
src/xpm/attrib.c
Normal file
302
src/xpm/attrib.c
Normal file
@@ -0,0 +1,302 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
* deal in the Software without restriction, including without limitation the
|
||||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
* sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||||
|
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||||
|
* in this Software without prior written authorization from GROUPE BULL.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*****************************************************************************\
|
||||||
|
* Attrib.c: *
|
||||||
|
* *
|
||||||
|
* XPM library *
|
||||||
|
* Functions related to the XpmAttributes structure *
|
||||||
|
* *
|
||||||
|
* Developed by Arnaud Le Hors *
|
||||||
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
#include "XpmI.h"
|
||||||
|
|
||||||
|
/* 3.2 backward compatibility code */
|
||||||
|
LFUNC(CreateOldColorTable, int, (XpmColor *ct, int ncolors,
|
||||||
|
XpmColor ***oldct));
|
||||||
|
|
||||||
|
LFUNC(FreeOldColorTable, void, (XpmColor **colorTable, int ncolors));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create a colortable compatible with the old style colortable
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
CreateOldColorTable(ct, ncolors, oldct)
|
||||||
|
XpmColor *ct;
|
||||||
|
int ncolors;
|
||||||
|
XpmColor ***oldct;
|
||||||
|
{
|
||||||
|
XpmColor **colorTable, **color;
|
||||||
|
int a;
|
||||||
|
|
||||||
|
colorTable = (XpmColor **) XpmMalloc(ncolors * sizeof(XpmColor *));
|
||||||
|
if (!colorTable) {
|
||||||
|
*oldct = NULL;
|
||||||
|
return (XpmNoMemory);
|
||||||
|
}
|
||||||
|
for (a = 0, color = colorTable; a < ncolors; a++, color++, ct++)
|
||||||
|
*color = ct;
|
||||||
|
*oldct = colorTable;
|
||||||
|
return (XpmSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
FreeOldColorTable(colorTable, ncolors)
|
||||||
|
XpmColor **colorTable;
|
||||||
|
int ncolors;
|
||||||
|
{
|
||||||
|
int a, b;
|
||||||
|
XpmColor **color;
|
||||||
|
char **sptr;
|
||||||
|
|
||||||
|
if (colorTable) {
|
||||||
|
for (a = 0, color = colorTable; a < ncolors; a++, color++) {
|
||||||
|
for (b = 0, sptr = (char **) *color; b <= NKEYS; b++, sptr++)
|
||||||
|
if (*sptr)
|
||||||
|
XpmFree(*sptr);
|
||||||
|
}
|
||||||
|
XpmFree(*colorTable);
|
||||||
|
XpmFree(colorTable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end 3.2 bc */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free the computed color table
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xpmFreeColorTable(colorTable, ncolors)
|
||||||
|
XpmColor *colorTable;
|
||||||
|
int ncolors;
|
||||||
|
{
|
||||||
|
int a, b;
|
||||||
|
XpmColor *color;
|
||||||
|
char **sptr;
|
||||||
|
|
||||||
|
if (colorTable) {
|
||||||
|
for (a = 0, color = colorTable; a < ncolors; a++, color++) {
|
||||||
|
for (b = 0, sptr = (char **) color; b <= NKEYS; b++, sptr++)
|
||||||
|
if (*sptr)
|
||||||
|
XpmFree(*sptr);
|
||||||
|
}
|
||||||
|
XpmFree(colorTable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free array of extensions
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
XpmFreeExtensions(extensions, nextensions)
|
||||||
|
XpmExtension *extensions;
|
||||||
|
int nextensions;
|
||||||
|
{
|
||||||
|
unsigned int i, j, nlines;
|
||||||
|
XpmExtension *ext;
|
||||||
|
char **sptr;
|
||||||
|
|
||||||
|
if (extensions) {
|
||||||
|
for (i = 0, ext = extensions; i < nextensions; i++, ext++) {
|
||||||
|
if (ext->name)
|
||||||
|
XpmFree(ext->name);
|
||||||
|
nlines = ext->nlines;
|
||||||
|
for (j = 0, sptr = ext->lines; j < nlines; j++, sptr++)
|
||||||
|
if (*sptr)
|
||||||
|
XpmFree(*sptr);
|
||||||
|
if (ext->lines)
|
||||||
|
XpmFree(ext->lines);
|
||||||
|
}
|
||||||
|
XpmFree(extensions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the XpmAttributes structure size
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
XpmAttributesSize()
|
||||||
|
{
|
||||||
|
return sizeof(XpmAttributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Init returned data to free safely later on
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xpmInitAttributes(attributes)
|
||||||
|
XpmAttributes *attributes;
|
||||||
|
{
|
||||||
|
if (attributes) {
|
||||||
|
attributes->pixels = NULL;
|
||||||
|
attributes->npixels = 0;
|
||||||
|
attributes->colorTable = NULL;
|
||||||
|
attributes->ncolors = 0;
|
||||||
|
/* 3.2 backward compatibility code */
|
||||||
|
attributes->hints_cmt = NULL;
|
||||||
|
attributes->colors_cmt = NULL;
|
||||||
|
attributes->pixels_cmt = NULL;
|
||||||
|
/* end 3.2 bc */
|
||||||
|
if (attributes->valuemask & XpmReturnExtensions) {
|
||||||
|
attributes->extensions = NULL;
|
||||||
|
attributes->nextensions = 0;
|
||||||
|
}
|
||||||
|
if (attributes->valuemask & XpmReturnAllocPixels) {
|
||||||
|
attributes->alloc_pixels = NULL;
|
||||||
|
attributes->nalloc_pixels = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fill in the XpmAttributes with the XpmImage and the XpmInfo
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xpmSetAttributes(attributes, image, info)
|
||||||
|
XpmAttributes *attributes;
|
||||||
|
XpmImage *image;
|
||||||
|
XpmInfo *info;
|
||||||
|
{
|
||||||
|
if (attributes->valuemask & XpmReturnColorTable) {
|
||||||
|
attributes->colorTable = image->colorTable;
|
||||||
|
attributes->ncolors = image->ncolors;
|
||||||
|
|
||||||
|
/* avoid deletion of copied data */
|
||||||
|
image->ncolors = 0;
|
||||||
|
image->colorTable = NULL;
|
||||||
|
}
|
||||||
|
/* 3.2 backward compatibility code */
|
||||||
|
else if (attributes->valuemask & XpmReturnInfos) {
|
||||||
|
int ErrorStatus;
|
||||||
|
|
||||||
|
ErrorStatus = CreateOldColorTable(image->colorTable, image->ncolors,
|
||||||
|
(XpmColor ***)
|
||||||
|
&attributes->colorTable);
|
||||||
|
|
||||||
|
/* if error just say we can't return requested data */
|
||||||
|
if (ErrorStatus != XpmSuccess) {
|
||||||
|
attributes->valuemask &= ~XpmReturnInfos;
|
||||||
|
if (!(attributes->valuemask & XpmReturnPixels)) {
|
||||||
|
XpmFree(attributes->pixels);
|
||||||
|
attributes->pixels = NULL;
|
||||||
|
attributes->npixels = 0;
|
||||||
|
}
|
||||||
|
attributes->ncolors = 0;
|
||||||
|
} else {
|
||||||
|
attributes->ncolors = image->ncolors;
|
||||||
|
attributes->hints_cmt = info->hints_cmt;
|
||||||
|
attributes->colors_cmt = info->colors_cmt;
|
||||||
|
attributes->pixels_cmt = info->pixels_cmt;
|
||||||
|
|
||||||
|
/* avoid deletion of copied data */
|
||||||
|
image->ncolors = 0;
|
||||||
|
image->colorTable = NULL;
|
||||||
|
info->hints_cmt = NULL;
|
||||||
|
info->colors_cmt = NULL;
|
||||||
|
info->pixels_cmt = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* end 3.2 bc */
|
||||||
|
if (attributes->valuemask & XpmReturnExtensions) {
|
||||||
|
attributes->extensions = info->extensions;
|
||||||
|
attributes->nextensions = info->nextensions;
|
||||||
|
|
||||||
|
/* avoid deletion of copied data */
|
||||||
|
info->extensions = NULL;
|
||||||
|
info->nextensions = 0;
|
||||||
|
}
|
||||||
|
if (info->valuemask & XpmHotspot) {
|
||||||
|
attributes->valuemask |= XpmHotspot;
|
||||||
|
attributes->x_hotspot = info->x_hotspot;
|
||||||
|
attributes->y_hotspot = info->y_hotspot;
|
||||||
|
}
|
||||||
|
attributes->valuemask |= XpmCharsPerPixel;
|
||||||
|
attributes->cpp = image->cpp;
|
||||||
|
attributes->valuemask |= XpmSize;
|
||||||
|
attributes->width = image->width;
|
||||||
|
attributes->height = image->height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free the XpmAttributes structure members
|
||||||
|
* but the structure itself
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
XpmFreeAttributes(attributes)
|
||||||
|
XpmAttributes *attributes;
|
||||||
|
{
|
||||||
|
if (attributes->valuemask & XpmReturnPixels && attributes->npixels) {
|
||||||
|
XpmFree(attributes->pixels);
|
||||||
|
attributes->pixels = NULL;
|
||||||
|
attributes->npixels = 0;
|
||||||
|
}
|
||||||
|
if (attributes->valuemask & XpmReturnColorTable) {
|
||||||
|
xpmFreeColorTable(attributes->colorTable, attributes->ncolors);
|
||||||
|
attributes->colorTable = NULL;
|
||||||
|
attributes->ncolors = 0;
|
||||||
|
}
|
||||||
|
/* 3.2 backward compatibility code */
|
||||||
|
else if (attributes->valuemask & XpmInfos) {
|
||||||
|
if (attributes->colorTable) {
|
||||||
|
FreeOldColorTable((XpmColor **) attributes->colorTable,
|
||||||
|
attributes->ncolors);
|
||||||
|
attributes->colorTable = NULL;
|
||||||
|
attributes->ncolors = 0;
|
||||||
|
}
|
||||||
|
if (attributes->hints_cmt) {
|
||||||
|
XpmFree(attributes->hints_cmt);
|
||||||
|
attributes->hints_cmt = NULL;
|
||||||
|
}
|
||||||
|
if (attributes->colors_cmt) {
|
||||||
|
XpmFree(attributes->colors_cmt);
|
||||||
|
attributes->colors_cmt = NULL;
|
||||||
|
}
|
||||||
|
if (attributes->pixels_cmt) {
|
||||||
|
XpmFree(attributes->pixels_cmt);
|
||||||
|
attributes->pixels_cmt = NULL;
|
||||||
|
}
|
||||||
|
if (attributes->pixels) {
|
||||||
|
XpmFree(attributes->pixels);
|
||||||
|
attributes->pixels = NULL;
|
||||||
|
attributes->npixels = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* end 3.2 bc */
|
||||||
|
if (attributes->valuemask & XpmReturnExtensions
|
||||||
|
&& attributes->nextensions) {
|
||||||
|
XpmFreeExtensions(attributes->extensions, attributes->nextensions);
|
||||||
|
attributes->extensions = NULL;
|
||||||
|
attributes->nextensions = 0;
|
||||||
|
}
|
||||||
|
if (attributes->valuemask & XpmReturnAllocPixels
|
||||||
|
&& attributes->nalloc_pixels) {
|
||||||
|
XpmFree(attributes->alloc_pixels);
|
||||||
|
attributes->alloc_pixels = NULL;
|
||||||
|
attributes->nalloc_pixels = 0;
|
||||||
|
}
|
||||||
|
attributes->valuemask = 0;
|
||||||
|
}
|
283
src/xpm/changes
283
src/xpm/changes
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -29,6 +29,259 @@
|
|||||||
* *
|
* *
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
|
|
||||||
|
3.4k (98/03/18)
|
||||||
|
|
||||||
|
ENHANCEMENTS:
|
||||||
|
- A new program called cxpm is provided to check on XPM files and help
|
||||||
|
figuring out where the file might be invalid.
|
||||||
|
- The FAQ and README are now in HTML.
|
||||||
|
|
||||||
|
BUGS CORRECTED:
|
||||||
|
- A bug in writing pixmaps out on an 32 bit depth visual and MSBFirst
|
||||||
|
machine.
|
||||||
|
- patch from Uwe Langenkamp <Uwe.Langenkamp@t-online.de>
|
||||||
|
- A severe bug in parsing the pixels section when an unknown character
|
||||||
|
is encountered.
|
||||||
|
|
||||||
|
3.4j (96/12/31)
|
||||||
|
|
||||||
|
ENHANCEMENTS:
|
||||||
|
- The XPM library can now be built under Amiga DOS. This entirely comes
|
||||||
|
from: Lorens Younes <d93-hyo@nada.kth.se>
|
||||||
|
See the README.AMIGA file for details.
|
||||||
|
- Changes for MSW: big performance improvement in ParseAndPutPixels(),
|
||||||
|
fixed creation of the mask in SetColor()
|
||||||
|
- patch from Jan Wielemaker <jan@swi.psy.uva.nl>
|
||||||
|
- makefiles are provided for VMS
|
||||||
|
- given by Martin P.J. Zinser m.zinser@gsi.de
|
||||||
|
- Imakefiles reworked to get smoother builds and fixes from:
|
||||||
|
- Paul DuBois dubois@primate.wisc.edu
|
||||||
|
- Larry Schwimmer schwim@cyclone.stanford.edu
|
||||||
|
- thanks to some code rearrangement the library is smaller (the size
|
||||||
|
reduction goes from 4 to 7% depending on the system)
|
||||||
|
|
||||||
|
BUGS CORRECTED:
|
||||||
|
- A severe bug (introduced in 3.4i as part of the sprintf
|
||||||
|
optimization) in code writing XPM extensions to a buffer
|
||||||
|
XpmCreateBufferFromImage/Pixmap.
|
||||||
|
- The XpmAttributes definition in xpm.h was declaring nalloc_colors to
|
||||||
|
be Bool, it's an int.
|
||||||
|
|
||||||
|
3.4i (96/09/13)
|
||||||
|
|
||||||
|
NEW FEATURES:
|
||||||
|
- The XPM library now allows the application to pass its own color
|
||||||
|
allocation/free functions. For this matter the following was done:
|
||||||
|
The XpmAttributes structure has three new fields alloc_color,
|
||||||
|
free_color, and color_closure. The following new valuemasks were
|
||||||
|
added XpmAllocColorFunc, XpmFreeColorsFunc, XpmColorClosure. And
|
||||||
|
two new types were defined XpmAllocColorFunc and XpmFreeColorsFunc.
|
||||||
|
See documentation for details.
|
||||||
|
|
||||||
|
ENHANCEMENTS:
|
||||||
|
- Windows NT support. It should compile and run fine based on the X
|
||||||
|
Consortium X11R6 distribution.
|
||||||
|
- The README file contains information to compile on Solaris with gcc.
|
||||||
|
- Part of the code has been optimized by using the value returned by
|
||||||
|
sprintf instead of calling strlen. Add the flag -DVOID_SPRINTF
|
||||||
|
if on your system sprintf returns void.
|
||||||
|
- patch from Thomas Ott thommy@rz.fh-augsburg.de
|
||||||
|
|
||||||
|
BUGS CORRECTED:
|
||||||
|
- XpmFree is now a real function (simply calling free by default).
|
||||||
|
|
||||||
|
CHANGES TO THE DOC:
|
||||||
|
- The documentation describes the new XpmAttributes fields and their
|
||||||
|
use.
|
||||||
|
|
||||||
|
3.4h (96/02/01)
|
||||||
|
|
||||||
|
NEW FEATURES:
|
||||||
|
- The XpmAttributes has a new member called 'alloc_close_colors' which
|
||||||
|
lets the caller specify whether close colors should be allocated
|
||||||
|
using XAllocColor or not. This is especially useful when one uses a
|
||||||
|
private colormap full of read/write cells.
|
||||||
|
The xpm.h header file define a new bitmap flag called
|
||||||
|
XpmAllocCloseColors to use along with this new slot.
|
||||||
|
- Dale Pease peased@bigbird.cso.gtegsc.com
|
||||||
|
- The XpmAttributes has a new member called 'bitmap_format' which lets
|
||||||
|
the caller specify the format of 1 bit depth images (XYBitmap or
|
||||||
|
ZPixmap). The xpm.h header file define a new bitmap flag called
|
||||||
|
XpmBitmapFormat to use along with this new field.
|
||||||
|
|
||||||
|
ENHANCEMENTS:
|
||||||
|
- XpmReadFileTo[Image/Pixmap], XpmCreate[Image/Pixmap]FromData,
|
||||||
|
XpmCreateImageFromDataFromBuffer functions do no longer use a
|
||||||
|
temporary XpmImage object, which reduces a lot the amount of memory
|
||||||
|
used. On the other hand it can take a little more time, but given the
|
||||||
|
following figures (based on sxpm) it is a real good trade-off.
|
||||||
|
|
||||||
|
Reading a 22x22 pixmap with 5 colors no time change is detected
|
||||||
|
using time:
|
||||||
|
real 0.3
|
||||||
|
user 0.1
|
||||||
|
sys 0.1
|
||||||
|
|
||||||
|
Reading a 1279x1023 pixmap with 14 colors (quite extreme case for
|
||||||
|
XPM!) the time goes from:
|
||||||
|
real 1.9
|
||||||
|
user 0.8
|
||||||
|
sys 0.8
|
||||||
|
|
||||||
|
to:
|
||||||
|
real 2.2
|
||||||
|
user 1.8
|
||||||
|
sys 0.3
|
||||||
|
|
||||||
|
Reading the 22x22 pixmap with 5 colors the memory usage (under
|
||||||
|
purify) goes from:
|
||||||
|
255256 code
|
||||||
|
55496 data/bss
|
||||||
|
163848 heap (peak use)
|
||||||
|
4248 stack
|
||||||
|
to:
|
||||||
|
271240 code
|
||||||
|
55472 data/bss
|
||||||
|
159752 heap (peak use)
|
||||||
|
4224 stack
|
||||||
|
|
||||||
|
And reading the 1279x1023 pixmap with 14 colors it goes from:
|
||||||
|
255256 code
|
||||||
|
55496 data/bss
|
||||||
|
6705160 heap (peak use)
|
||||||
|
4280 stack
|
||||||
|
to:
|
||||||
|
271240 code
|
||||||
|
55472 data/bss
|
||||||
|
1732616 heap (peak use)
|
||||||
|
4264 stack
|
||||||
|
|
||||||
|
This clearly shows that while for small pixmaps there is no real
|
||||||
|
difference on both sides, for large pixmaps this makes a huge
|
||||||
|
difference about the amount of memory used and it is not much
|
||||||
|
slower.
|
||||||
|
|
||||||
|
Note that you can still get the old behavior using both
|
||||||
|
XpmReadFileToXpmImage and XpmCreate[Image/Pixmap]FromXpmImage instead
|
||||||
|
of XpmReadFileTo[Image/Pixmap]. Once more XPM gives you the choice!
|
||||||
|
|
||||||
|
BUGS CORRECTED:
|
||||||
|
- when defined locally the global symbols strcasecmp and strdup are
|
||||||
|
now called xpmstrcasecmp and xpmstrdup to avoid any possible
|
||||||
|
conflict.
|
||||||
|
- VMS has a bogus file system which requires a work around in
|
||||||
|
XpmReadFileToBuffer.
|
||||||
|
- patch from Bob.Deen@jpl.nasa.gov
|
||||||
|
- the type of the exactColors attribute has been changed from unsigned
|
||||||
|
int to Bool.
|
||||||
|
|
||||||
|
CHANGES TO THE DOC:
|
||||||
|
- the documentation describes the new XpmAttributes fields
|
||||||
|
alloc_close_colors and bitmap_format.
|
||||||
|
|
||||||
|
3.4g (95/10/08)
|
||||||
|
|
||||||
|
ENHANCEMENTS:
|
||||||
|
- The XpmAttributes structure has now two new slots: alloc_pixels and
|
||||||
|
nalloc_pixels in order to provide an easy way to free allocated
|
||||||
|
colors. The new bitmask XpmReturnAllocPixels should be used to
|
||||||
|
request this data through the valuemask. Unless you really know why,
|
||||||
|
you should use this instead of XpmReturnPixels, pixels, and npixels.
|
||||||
|
- the XPM1 format parsing has been improved.
|
||||||
|
- patch from Chuck Thompson <cthomp@cs.uiuc.edu>
|
||||||
|
- compilers defining _STDC_ to something different from 1 are now
|
||||||
|
considered as ANSI compilers.
|
||||||
|
- the README file provides now more info on how to build XPM depending
|
||||||
|
on the system.
|
||||||
|
|
||||||
|
BUGS CORRECTED:
|
||||||
|
- a bug introduced in 3.4f in the XPM1 format parsing function.
|
||||||
|
- fix from Chuck Thompson <cthomp@cs.uiuc.edu>
|
||||||
|
- the hashtable was not free when the color parsing failed.
|
||||||
|
- patch from ackley@cs.unm.edu (David Ackley)
|
||||||
|
- the close color mechanism wasn't used if one of the closeness
|
||||||
|
parameter was null. Now only one needs to be different from 0.
|
||||||
|
Lorens Younes d93-hyo@nada.kth.se
|
||||||
|
- parsing of long comments failed with a segmentation fault.
|
||||||
|
|
||||||
|
CHANGES TO THE DOC:
|
||||||
|
- the documentation describes the new XpmAttributes fields
|
||||||
|
alloc_pixels and nalloc_pixels and how they are used.
|
||||||
|
|
||||||
|
3.4f (95/05/29)
|
||||||
|
|
||||||
|
ENHANCEMENTS:
|
||||||
|
- Defines IMAKE_DEFINES in the top Imakefile so one can easily avoid
|
||||||
|
building the shared library.
|
||||||
|
- Add some information about the installation process in the README.
|
||||||
|
- filenames are surrounded with quotes when calling gzip or compress in
|
||||||
|
order to allow spaces within filenames.
|
||||||
|
- William Parn <parn@fgm.com>
|
||||||
|
- the compilation and the shared library building should be smoother
|
||||||
|
on Alpha OSF/1.
|
||||||
|
- patch from Dale Moore <Dale.Moore@CS.cmu.edu>
|
||||||
|
|
||||||
|
BUGS CORRECTED:
|
||||||
|
- a segmentation fault occurring in some weird case.
|
||||||
|
|
||||||
|
3.4e (95/03/01)
|
||||||
|
|
||||||
|
ENHANCEMENTS:
|
||||||
|
- The top Imakefile passes CDEBUGFLAGS and DEFINES to subdirs. Thus
|
||||||
|
only this Imakefile should need to be edited by users.
|
||||||
|
- FAQ includes the answer to the question "How can I get a non
|
||||||
|
rectangular icon using XPM ?"
|
||||||
|
- VMS support updated
|
||||||
|
- patch from Martin P.J. Zinser m.zinser@gsi.de
|
||||||
|
|
||||||
|
BUGS CORRECTED:
|
||||||
|
- XpmCreateImageFromXpmImage() called from XpmReadFileToPixmap() could
|
||||||
|
lead to a segmentation fault since free was called on a memory block
|
||||||
|
size variable instead of the block itself. Note: this bug has been
|
||||||
|
introduced in 3.4d.
|
||||||
|
|
||||||
|
3.4d (95/01/31)
|
||||||
|
|
||||||
|
ENHANCEMENTS:
|
||||||
|
- sxpm now supports a -version option command.
|
||||||
|
|
||||||
|
BUGS CORRECTED:
|
||||||
|
- the list of pixels returned in XpmAttributes was wrong when two
|
||||||
|
colors were defined as None in the read XPM
|
||||||
|
- Lionel.Mallet@sophia.inria.fr
|
||||||
|
- the parser was skipping whitespace reading extensions strings. This
|
||||||
|
has been fixed so extensions lines are now returned exactly as they
|
||||||
|
are.
|
||||||
|
- some compilation control added for the dec alpha with X11R5 (LONG64)
|
||||||
|
- patch from Fredrik Lundh <Fredrik_Lundh@ivab.se>
|
||||||
|
- when writing an XPM file, '-' characters are replaced with '_'
|
||||||
|
characters in the array name, in order to get a valid C syntax name.
|
||||||
|
- XYPixmap format images were not correctly handled.
|
||||||
|
- XPM1 file with names using multiple '_' characters are now handled
|
||||||
|
correctly.
|
||||||
|
- todd@erda.rl.af.mil (Todd Gleason)
|
||||||
|
|
||||||
|
3.4c (94/06/06)
|
||||||
|
|
||||||
|
Yes, this is kind of quick. But this is because no code has been modified,
|
||||||
|
this is just a new packaging to make the whole stuff more suitable to the
|
||||||
|
X development team's requests for inclusion in the R6 contrib.
|
||||||
|
|
||||||
|
ENHANCEMENTS:
|
||||||
|
- Several filenames were too long to fit without any conflict on DOS
|
||||||
|
and CD-ROM filesystems. They have been renamed.
|
||||||
|
- Imakefiles use XCOMM for comments instead of the # character.
|
||||||
|
- the Postscript documentation file doc/xpm.ps is now distributed as
|
||||||
|
doc/xpm.PS.gz and allows browsing with tools such as ghostview.
|
||||||
|
- Besides, parts of lib/misc.c have been moved to several new files,
|
||||||
|
and some functions of data.c have been moved to other files in
|
||||||
|
order to get a better link profile.
|
||||||
|
- I've also added a FAQ hoping this will prevent people from
|
||||||
|
continuously filling my mailbox with the same questions.
|
||||||
|
- sxpm.c includes <X11/xpm.h> instead of "xpm.h" and BUILDINCTOP is
|
||||||
|
used in Makefiles as expected.
|
||||||
|
- Everything can be done simply using "xmkmf -a" and "make".
|
||||||
|
|
||||||
3.4b (94/05/24)
|
3.4b (94/05/24)
|
||||||
|
|
||||||
ENHANCEMENTS:
|
ENHANCEMENTS:
|
||||||
@@ -109,10 +362,10 @@
|
|||||||
defined.
|
defined.
|
||||||
- The XpmInfo struct has been extended to avoid having to deal with an
|
- The XpmInfo struct has been extended to avoid having to deal with an
|
||||||
XpmAttributes at the lower level. The idea is that all the data
|
XpmAttributes at the lower level. The idea is that all the data
|
||||||
stored in an Xpm file can be retreive through both an XpmImage and
|
stored in an Xpm file can be retrieve through both an XpmImage and
|
||||||
an XpmInfo struct. See the documentation for details.
|
an XpmInfo struct. See the documentation for details.
|
||||||
- XpmUndefPixel is defined and exported by xpm.h in order to let
|
- XpmUndefPixel is defined and exported by xpm.h in order to let
|
||||||
clients providing their own colorTable when writting out an Xpm file.
|
clients providing their own colorTable when writing out an Xpm file.
|
||||||
See the documentation for details.
|
See the documentation for details.
|
||||||
- in sxpm/sxpm.c, set attribute XtNinput to True on toplevel widget.
|
- in sxpm/sxpm.c, set attribute XtNinput to True on toplevel widget.
|
||||||
Windows that don't "take" input, never get focus, as mandated by
|
Windows that don't "take" input, never get focus, as mandated by
|
||||||
@@ -122,7 +375,7 @@
|
|||||||
patch from simon@lia.di.epfl.ch (Simon Leinen)
|
patch from simon@lia.di.epfl.ch (Simon Leinen)
|
||||||
|
|
||||||
NEW FEATURES:
|
NEW FEATURES:
|
||||||
- a new funtion and a new define should help client figuring out with
|
- a new function and a new define should help client figuring out with
|
||||||
which Xpm library version they are working. These are
|
which Xpm library version they are working. These are
|
||||||
XpmIncludeVersion and XpmLibraryVersion().
|
XpmIncludeVersion and XpmLibraryVersion().
|
||||||
|
|
||||||
@@ -145,7 +398,7 @@
|
|||||||
BUGS CORRECTED:
|
BUGS CORRECTED:
|
||||||
- reading some binary file was leading to a bus error.
|
- reading some binary file was leading to a bus error.
|
||||||
- patch from Detlef Schmier <detlef@mfr.dec.com>
|
- patch from Detlef Schmier <detlef@mfr.dec.com>
|
||||||
- the ? character is no longer used when writting an XPM file in order
|
- the ? character is no longer used when writing an XPM file in order
|
||||||
to avoid possible ANSI trigraphs.
|
to avoid possible ANSI trigraphs.
|
||||||
|
|
||||||
3.3alpha (93/08/13)
|
3.3alpha (93/08/13)
|
||||||
@@ -161,7 +414,7 @@
|
|||||||
- a separate distribution called xpm-contrib is available. This
|
- a separate distribution called xpm-contrib is available. This
|
||||||
includes the converters which used to be part of this distribution
|
includes the converters which used to be part of this distribution
|
||||||
plus:
|
plus:
|
||||||
two new appplications:
|
two new applications:
|
||||||
* nexpm to draw a pixmap in *any* existing window from
|
* nexpm to draw a pixmap in *any* existing window from
|
||||||
Ralph Betza <gnohmon@ssiny.com>
|
Ralph Betza <gnohmon@ssiny.com>
|
||||||
* xpmview to display a list of Xpm files from
|
* xpmview to display a list of Xpm files from
|
||||||
@@ -255,7 +508,7 @@
|
|||||||
- The documentation has been ported from LaTeX to FrameMaker and is
|
- The documentation has been ported from LaTeX to FrameMaker and is
|
||||||
now included in the distribution in its PostScript form (doc/xpm.ps).
|
now included in the distribution in its PostScript form (doc/xpm.ps).
|
||||||
Source files are available on request.
|
Source files are available on request.
|
||||||
Also the documentation has been reoreganized and includes a table of
|
Also the documentation has been reorganized and includes a table of
|
||||||
contents and an index of the functions (the number of functions
|
contents and an index of the functions (the number of functions
|
||||||
increasing this became a requisite).
|
increasing this became a requisite).
|
||||||
|
|
||||||
@@ -272,7 +525,7 @@
|
|||||||
BUGS CORRECTED:
|
BUGS CORRECTED:
|
||||||
- Intrinsic.h is no longer included.
|
- Intrinsic.h is no longer included.
|
||||||
- bzero is defined as memset on SYSV and SVR4.
|
- bzero is defined as memset on SYSV and SVR4.
|
||||||
- some memory initialisation bug concerning XpmAttributes.
|
- some memory initialization bug concerning XpmAttributes.
|
||||||
|
|
||||||
3.2d (93/01/27)
|
3.2d (93/01/27)
|
||||||
|
|
||||||
@@ -317,7 +570,7 @@
|
|||||||
- Jason Patterson <jasonp@fitmail.qut.edu.au>
|
- Jason Patterson <jasonp@fitmail.qut.edu.au>
|
||||||
- errors while parsing or allocating colors now revert to other
|
- errors while parsing or allocating colors now revert to other
|
||||||
visual defaults, creating pixmap/image as expected, and returning
|
visual defaults, creating pixmap/image as expected, and returning
|
||||||
XpmSuccess. The old behaviour of XpmColorError being returned and no
|
XpmSuccess. The old behavior of XpmColorError being returned and no
|
||||||
pixmap/image being created can be retained by setting the
|
pixmap/image being created can be retained by setting the
|
||||||
exactColors attribute.
|
exactColors attribute.
|
||||||
- Jason Patterson <jasonp@fitmail.qut.edu.au>
|
- Jason Patterson <jasonp@fitmail.qut.edu.au>
|
||||||
@@ -408,7 +661,7 @@
|
|||||||
[-rgb filename] Search color names in the rgb text file
|
[-rgb filename] Search color names in the rgb text file
|
||||||
'filename'.
|
'filename'.
|
||||||
|
|
||||||
if no input is specified sxpm reads from stdandard input.
|
if no input is specified sxpm reads from standard input.
|
||||||
|
|
||||||
|
|
||||||
- Xpm functions and Ppm converters now deal with multiword colornames.
|
- Xpm functions and Ppm converters now deal with multiword colornames.
|
||||||
@@ -513,7 +766,7 @@
|
|||||||
the XCreatePixmapFromData function later on.
|
the XCreatePixmapFromData function later on.
|
||||||
- a new structure: XpmAttributes which replace the XpmInfo structure
|
- a new structure: XpmAttributes which replace the XpmInfo structure
|
||||||
and which leads to a much simpler API with less arguments.
|
and which leads to a much simpler API with less arguments.
|
||||||
- arguments such as visual, colormap and depth are optionnal, default
|
- arguments such as visual, colormap and depth are optional, default
|
||||||
values are taken if omitted.
|
values are taken if omitted.
|
||||||
- parsing and allocating color failures don't simply break anymore. If
|
- parsing and allocating color failures don't simply break anymore. If
|
||||||
another default color can be found it is used and a PixmapColorError
|
another default color can be found it is used and a PixmapColorError
|
||||||
@@ -541,7 +794,7 @@
|
|||||||
BUGS CORRECTED:
|
BUGS CORRECTED:
|
||||||
- I've again improved the memory management.
|
- I've again improved the memory management.
|
||||||
- the parser is also improved.
|
- the parser is also improved.
|
||||||
- when writting a pixmap to a file the variable name could be
|
- when writing a pixmap to a file the variable name could be
|
||||||
"plaid.xpm" which is not valid in C. Now the extension name is cut off
|
"plaid.xpm" which is not valid in C. Now the extension name is cut off
|
||||||
to give "plaid" as variable name.
|
to give "plaid" as variable name.
|
||||||
- reading multiple words colornames such as "peach puff" where leading
|
- reading multiple words colornames such as "peach puff" where leading
|
||||||
@@ -592,7 +845,7 @@
|
|||||||
BUGS CORRECTED:
|
BUGS CORRECTED:
|
||||||
- the memory management has been much improved in order to avoid
|
- the memory management has been much improved in order to avoid
|
||||||
memory leaks.
|
memory leaks.
|
||||||
- the XImage building algorythm has been changed to support correctly
|
- the XImage building algorithm has been changed to support correctly
|
||||||
different visual depths. There is special code to handle depths 1, 4,
|
different visual depths. There is special code to handle depths 1, 4,
|
||||||
6, 8, 24, and 32 to build the image and send it in one whack, and
|
6, 8, 24, and 32 to build the image and send it in one whack, and
|
||||||
other depths are supported by building the image with XPutPixel which
|
other depths are supported by building the image with XPutPixel which
|
||||||
@@ -671,7 +924,7 @@
|
|||||||
2.5 (90/10/17)
|
2.5 (90/10/17)
|
||||||
|
|
||||||
BUGS CORRECTED:
|
BUGS CORRECTED:
|
||||||
- XWritePixmapFile was not closing the file while ending normaly.
|
- XWritePixmapFile was not closing the file while ending normally.
|
||||||
|
|
||||||
2.4 (90/09/06)
|
2.4 (90/09/06)
|
||||||
|
|
||||||
@@ -690,7 +943,7 @@
|
|||||||
2.3 (90/08/30)
|
2.3 (90/08/30)
|
||||||
|
|
||||||
BUGS CORRECTED:
|
BUGS CORRECTED:
|
||||||
- handle monochrom display correctly,
|
- handle monochrome display correctly,
|
||||||
- comments can be empty.
|
- comments can be empty.
|
||||||
|
|
||||||
2.2 (90/08/27)
|
2.2 (90/08/27)
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************\
|
/*****************************************************************************\
|
||||||
* XpmCrBufFrI.c: *
|
* CrBufFrI.c: *
|
||||||
* *
|
* *
|
||||||
* XPM library *
|
* XPM library *
|
||||||
* Scan an image and possibly its mask and create an XPM buffer *
|
* Scan an image and possibly its mask and create an XPM buffer *
|
||||||
@@ -32,16 +32,7 @@
|
|||||||
* Developed by Arnaud Le Hors *
|
* Developed by Arnaud Le Hors *
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
#include "xpm34p.h"
|
#include "XpmI.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,
|
LFUNC(WriteColors, int, (char **dataptr, unsigned int *data_size,
|
||||||
unsigned int *used_size, XpmColor *colors,
|
unsigned int *used_size, XpmColor *colors,
|
||||||
@@ -59,8 +50,12 @@ LFUNC(ExtensionsSize, int, (XpmExtension *ext, unsigned int num));
|
|||||||
LFUNC(CommentsSize, int, (XpmInfo *info));
|
LFUNC(CommentsSize, int, (XpmInfo *info));
|
||||||
|
|
||||||
int
|
int
|
||||||
XpmCreateBufferFromImage(Display *display, char **buffer_return, XImage *image,
|
XpmCreateBufferFromImage(display, buffer_return, image, shapeimage, attributes)
|
||||||
XImage *shapeimage, XpmAttributes *attributes)
|
Display *display;
|
||||||
|
char **buffer_return;
|
||||||
|
XImage *image;
|
||||||
|
XImage *shapeimage;
|
||||||
|
XpmAttributes *attributes;
|
||||||
{
|
{
|
||||||
XpmImage xpmimage;
|
XpmImage xpmimage;
|
||||||
XpmInfo info;
|
XpmInfo info;
|
||||||
@@ -95,13 +90,15 @@ XpmCreateBufferFromImage(Display *display, char **buffer_return, XImage *image,
|
|||||||
#undef RETURN
|
#undef RETURN
|
||||||
#define RETURN(status) \
|
#define RETURN(status) \
|
||||||
{ \
|
{ \
|
||||||
if (ptr) \
|
ErrorStatus = status; \
|
||||||
XpmFree(ptr); \
|
goto error; \
|
||||||
return(status); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
XpmCreateBufferFromXpmImage(char **buffer_return, XpmImage *image, XpmInfo *info)
|
XpmCreateBufferFromXpmImage(buffer_return, image, info)
|
||||||
|
char **buffer_return;
|
||||||
|
XpmImage *image;
|
||||||
|
XpmInfo *info;
|
||||||
{
|
{
|
||||||
/* calculation variables */
|
/* calculation variables */
|
||||||
int ErrorStatus;
|
int ErrorStatus;
|
||||||
@@ -124,8 +121,13 @@ XpmCreateBufferFromXpmImage(char **buffer_return, XpmImage *image, XpmInfo *info
|
|||||||
cmt_size = CommentsSize(info);
|
cmt_size = CommentsSize(info);
|
||||||
|
|
||||||
/* write the header line */
|
/* write the header line */
|
||||||
|
#ifndef VOID_SPRINTF
|
||||||
|
used_size =
|
||||||
|
#endif
|
||||||
sprintf(buf, "/* XPM */\nstatic char * image_name[] = {\n");
|
sprintf(buf, "/* XPM */\nstatic char * image_name[] = {\n");
|
||||||
|
#ifdef VOID_SPRINTF
|
||||||
used_size = strlen(buf);
|
used_size = strlen(buf);
|
||||||
|
#endif
|
||||||
ptr_size = used_size + ext_size + cmt_size + 1;
|
ptr_size = used_size + ext_size + cmt_size + 1;
|
||||||
ptr = (char *) XpmMalloc(ptr_size);
|
ptr = (char *) XpmMalloc(ptr_size);
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
@@ -134,23 +136,48 @@ XpmCreateBufferFromXpmImage(char **buffer_return, XpmImage *image, XpmInfo *info
|
|||||||
|
|
||||||
/* write the values line */
|
/* write the values line */
|
||||||
if (cmts && info->hints_cmt) {
|
if (cmts && info->hints_cmt) {
|
||||||
|
#ifndef VOID_SPRINTF
|
||||||
|
used_size +=
|
||||||
|
#endif
|
||||||
sprintf(ptr + used_size, "/*%s*/\n", info->hints_cmt);
|
sprintf(ptr + used_size, "/*%s*/\n", info->hints_cmt);
|
||||||
|
#ifdef VOID_SPRINTF
|
||||||
used_size += strlen(info->hints_cmt) + 5;
|
used_size += strlen(info->hints_cmt) + 5;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifndef VOID_SPRINTF
|
||||||
|
l =
|
||||||
|
#endif
|
||||||
sprintf(buf, "\"%d %d %d %d", image->width, image->height,
|
sprintf(buf, "\"%d %d %d %d", image->width, image->height,
|
||||||
image->ncolors, image->cpp);
|
image->ncolors, image->cpp);
|
||||||
|
#ifdef VOID_SPRINTF
|
||||||
l = strlen(buf);
|
l = strlen(buf);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (info && (info->valuemask & XpmHotspot)) {
|
if (info && (info->valuemask & XpmHotspot)) {
|
||||||
|
#ifndef VOID_SPRINTF
|
||||||
|
l +=
|
||||||
|
#endif
|
||||||
sprintf(buf + l, " %d %d", info->x_hotspot, info->y_hotspot);
|
sprintf(buf + l, " %d %d", info->x_hotspot, info->y_hotspot);
|
||||||
|
#ifdef VOID_SPRINTF
|
||||||
l = strlen(buf);
|
l = strlen(buf);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (extensions) {
|
if (extensions) {
|
||||||
|
#ifndef VOID_SPRINTF
|
||||||
|
l +=
|
||||||
|
#endif
|
||||||
sprintf(buf + l, " XPMEXT");
|
sprintf(buf + l, " XPMEXT");
|
||||||
|
#ifdef VOID_SPRINTF
|
||||||
l = strlen(buf);
|
l = strlen(buf);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifndef VOID_SPRINTF
|
||||||
|
l +=
|
||||||
|
#endif
|
||||||
sprintf(buf + l, "\",\n");
|
sprintf(buf + l, "\",\n");
|
||||||
|
#ifdef VOID_SPRINTF
|
||||||
l = strlen(buf);
|
l = strlen(buf);
|
||||||
|
#endif
|
||||||
ptr_size += l;
|
ptr_size += l;
|
||||||
p = (char *) XpmRealloc(ptr, ptr_size);
|
p = (char *) XpmRealloc(ptr, ptr_size);
|
||||||
if (!p)
|
if (!p)
|
||||||
@@ -161,8 +188,13 @@ XpmCreateBufferFromXpmImage(char **buffer_return, XpmImage *image, XpmInfo *info
|
|||||||
|
|
||||||
/* write colors */
|
/* write colors */
|
||||||
if (cmts && info->colors_cmt) {
|
if (cmts && info->colors_cmt) {
|
||||||
|
#ifndef VOID_SPRINTF
|
||||||
|
used_size +=
|
||||||
|
#endif
|
||||||
sprintf(ptr + used_size, "/*%s*/\n", info->colors_cmt);
|
sprintf(ptr + used_size, "/*%s*/\n", info->colors_cmt);
|
||||||
|
#ifdef VOID_SPRINTF
|
||||||
used_size += strlen(info->colors_cmt) + 5;
|
used_size += strlen(info->colors_cmt) + 5;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
ErrorStatus = WriteColors(&ptr, &ptr_size, &used_size,
|
ErrorStatus = WriteColors(&ptr, &ptr_size, &used_size,
|
||||||
image->colorTable, image->ncolors, image->cpp);
|
image->colorTable, image->ncolors, image->cpp);
|
||||||
@@ -171,9 +203,9 @@ XpmCreateBufferFromXpmImage(char **buffer_return, XpmImage *image, XpmInfo *info
|
|||||||
RETURN(ErrorStatus);
|
RETURN(ErrorStatus);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* now we know the exact size we needed, realloc the data 4 = 1 (for
|
* now we know the exact size we need, realloc the data
|
||||||
* '"') + 3 (for '",\n') 1 = - 2 is because the last line does not end
|
* 4 = 1 (for '"') + 3 (for '",\n')
|
||||||
* with ',\n' + 3 (for '};\n')
|
* 1 = - 2 (because the last line does not end with ',\n') + 3 (for '};\n')
|
||||||
*/
|
*/
|
||||||
ptr_size += image->height * (image->width * image->cpp + 4) + 1;
|
ptr_size += image->height * (image->width * image->cpp + 4) + 1;
|
||||||
|
|
||||||
@@ -184,8 +216,13 @@ XpmCreateBufferFromXpmImage(char **buffer_return, XpmImage *image, XpmInfo *info
|
|||||||
|
|
||||||
/* print pixels */
|
/* print pixels */
|
||||||
if (cmts && info->pixels_cmt) {
|
if (cmts && info->pixels_cmt) {
|
||||||
|
#ifndef VOID_SPRINTF
|
||||||
|
used_size +=
|
||||||
|
#endif
|
||||||
sprintf(ptr + used_size, "/*%s*/\n", info->pixels_cmt);
|
sprintf(ptr + used_size, "/*%s*/\n", info->pixels_cmt);
|
||||||
|
#ifdef VOID_SPRINTF
|
||||||
used_size += strlen(info->pixels_cmt) + 5;
|
used_size += strlen(info->pixels_cmt) + 5;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
WritePixels(ptr + used_size, &used_size, image->width, image->height,
|
WritePixels(ptr + used_size, &used_size, image->width, image->height,
|
||||||
image->cpp, image->data, image->colorTable);
|
image->cpp, image->data, image->colorTable);
|
||||||
@@ -196,16 +233,27 @@ XpmCreateBufferFromXpmImage(char **buffer_return, XpmImage *image, XpmInfo *info
|
|||||||
info->extensions, info->nextensions);
|
info->extensions, info->nextensions);
|
||||||
|
|
||||||
/* close the array */
|
/* close the array */
|
||||||
sprintf(ptr + used_size, "};\n");
|
strcpy(ptr + used_size, "};\n");
|
||||||
|
|
||||||
*buffer_return = ptr;
|
*buffer_return = ptr;
|
||||||
|
|
||||||
return (XpmSuccess);
|
return (XpmSuccess);
|
||||||
|
|
||||||
|
/* exit point in case of error, free only locally allocated variables */
|
||||||
|
error:
|
||||||
|
if (ptr)
|
||||||
|
XpmFree(ptr);
|
||||||
|
return (ErrorStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
WriteColors(char **dataptr, unsigned int *data_size, unsigned int *used_size,
|
WriteColors(dataptr, data_size, used_size, colors, ncolors, cpp)
|
||||||
XpmColor *colors, unsigned int ncolors, unsigned int cpp)
|
char **dataptr;
|
||||||
|
unsigned int *data_size;
|
||||||
|
unsigned int *used_size;
|
||||||
|
XpmColor *colors;
|
||||||
|
unsigned int ncolors;
|
||||||
|
unsigned int cpp;
|
||||||
{
|
{
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
unsigned int a, key, l;
|
unsigned int a, key, l;
|
||||||
@@ -222,12 +270,17 @@ WriteColors(char **dataptr, unsigned int *data_size, unsigned int *used_size,
|
|||||||
|
|
||||||
for (key = 1; key <= NKEYS; key++, defaults++) {
|
for (key = 1; key <= NKEYS; key++, defaults++) {
|
||||||
if (s2 = *defaults) {
|
if (s2 = *defaults) {
|
||||||
|
#ifndef VOID_SPRINTF
|
||||||
|
s +=
|
||||||
|
#endif
|
||||||
sprintf(s, "\t%s %s", xpmColorKeys[key - 1], s2);
|
sprintf(s, "\t%s %s", xpmColorKeys[key - 1], s2);
|
||||||
|
#ifdef VOID_SPRINTF
|
||||||
s += strlen(s);
|
s += strlen(s);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strcpy(s, "\",\n");
|
strcpy(s, "\",\n");
|
||||||
l = strlen(buf);
|
l = s + 3 - buf;
|
||||||
s = (char *) XpmRealloc(*dataptr, *data_size + l);
|
s = (char *) XpmRealloc(*dataptr, *data_size + l);
|
||||||
if (!s)
|
if (!s)
|
||||||
return (XpmNoMemory);
|
return (XpmNoMemory);
|
||||||
@@ -240,8 +293,14 @@ WriteColors(char **dataptr, unsigned int *data_size, unsigned int *used_size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
WritePixels(char *dataptr, unsigned int *used_size, unsigned int width, unsigned int height,
|
WritePixels(dataptr, used_size, width, height, cpp, pixels, colors)
|
||||||
unsigned int cpp, unsigned int *pixels, XpmColor *colors)
|
char *dataptr;
|
||||||
|
unsigned int *used_size;
|
||||||
|
unsigned int width;
|
||||||
|
unsigned int height;
|
||||||
|
unsigned int cpp;
|
||||||
|
unsigned int *pixels;
|
||||||
|
XpmColor *colors;
|
||||||
{
|
{
|
||||||
char *s = dataptr;
|
char *s = dataptr;
|
||||||
unsigned int x, y, h;
|
unsigned int x, y, h;
|
||||||
@@ -267,7 +326,9 @@ WritePixels(char *dataptr, unsigned int *used_size, unsigned int width, unsigned
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ExtensionsSize(XpmExtension *ext, unsigned int num)
|
ExtensionsSize(ext, num)
|
||||||
|
XpmExtension *ext;
|
||||||
|
unsigned int num;
|
||||||
{
|
{
|
||||||
unsigned int x, y, a, size;
|
unsigned int x, y, a, size;
|
||||||
char **line;
|
char **line;
|
||||||
@@ -286,19 +347,33 @@ ExtensionsSize(XpmExtension *ext, unsigned int num)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
WriteExtensions(char *dataptr, unsigned int *used_size, XpmExtension *ext, unsigned int num)
|
WriteExtensions(dataptr, used_size, ext, num)
|
||||||
|
char *dataptr;
|
||||||
|
unsigned int *used_size;
|
||||||
|
XpmExtension *ext;
|
||||||
|
unsigned int num;
|
||||||
{
|
{
|
||||||
unsigned int x, y, a;
|
unsigned int x, y, a;
|
||||||
char **line;
|
char **line;
|
||||||
char *s = dataptr;
|
char *s = dataptr;
|
||||||
|
|
||||||
for (x = 0; x < num; x++, ext++) {
|
for (x = 0; x < num; x++, ext++) {
|
||||||
|
#ifndef VOID_SPRINTF
|
||||||
|
s +=
|
||||||
|
#endif
|
||||||
sprintf(s, ",\n\"XPMEXT %s\"", ext->name);
|
sprintf(s, ",\n\"XPMEXT %s\"", ext->name);
|
||||||
|
#ifdef VOID_SPRINTF
|
||||||
s += strlen(ext->name) + 11;
|
s += strlen(ext->name) + 11;
|
||||||
|
#endif
|
||||||
a = ext->nlines;
|
a = ext->nlines;
|
||||||
for (y = 0, line = ext->lines; y < a; y++, line++) {
|
for (y = 0, line = ext->lines; y < a; y++, line++) {
|
||||||
|
#ifndef VOID_SPRINTF
|
||||||
|
s +=
|
||||||
|
#endif
|
||||||
sprintf(s, ",\n\"%s\"", *line);
|
sprintf(s, ",\n\"%s\"", *line);
|
||||||
|
#ifdef VOID_SPRINTF
|
||||||
s += strlen(*line) + 4;
|
s += strlen(*line) + 4;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strcpy(s, ",\n\"XPMENDEXT\"");
|
strcpy(s, ",\n\"XPMENDEXT\"");
|
||||||
@@ -306,7 +381,8 @@ WriteExtensions(char *dataptr, unsigned int *used_size, XpmExtension *ext, unsig
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
CommentsSize(XpmInfo *info)
|
CommentsSize(info)
|
||||||
|
XpmInfo *info;
|
||||||
{
|
{
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
|
@@ -1,82 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************\
|
/*****************************************************************************\
|
||||||
* XpmCrDataFI.c: *
|
* CrDataFI.c: *
|
||||||
* *
|
* *
|
||||||
* XPM library *
|
* XPM library *
|
||||||
* Scan an image and possibly its mask and create an XPM array *
|
* Scan an image and possibly its mask and create an XPM array *
|
||||||
@@ -32,16 +32,7 @@
|
|||||||
* Developed by Arnaud Le Hors *
|
* Developed by Arnaud Le Hors *
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
#include "xpm34p.h"
|
#include "XpmI.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,
|
LFUNC(CreateColors, int, (char **dataptr, unsigned int *data_size,
|
||||||
XpmColor *colors, unsigned int ncolors,
|
XpmColor *colors, unsigned int ncolors,
|
||||||
@@ -60,8 +51,12 @@ LFUNC(CreateExtensions, void, (char **dataptr, unsigned int offset,
|
|||||||
unsigned int ext_nlines));
|
unsigned int ext_nlines));
|
||||||
|
|
||||||
int
|
int
|
||||||
XpmCreateDataFromImage(Display *display, char ***data_return, XImage *image,
|
XpmCreateDataFromImage(display, data_return, image, shapeimage, attributes)
|
||||||
XImage *shapeimage, XpmAttributes *attributes)
|
Display *display;
|
||||||
|
char ***data_return;
|
||||||
|
XImage *image;
|
||||||
|
XImage *shapeimage;
|
||||||
|
XpmAttributes *attributes;
|
||||||
{
|
{
|
||||||
XpmImage xpmimage;
|
XpmImage xpmimage;
|
||||||
XpmInfo info;
|
XpmInfo info;
|
||||||
@@ -93,17 +88,15 @@ XpmCreateDataFromImage(Display *display, char ***data_return, XImage *image,
|
|||||||
#undef RETURN
|
#undef RETURN
|
||||||
#define RETURN(status) \
|
#define RETURN(status) \
|
||||||
{ \
|
{ \
|
||||||
if (header) { \
|
ErrorStatus = status; \
|
||||||
for (l = 0; l < header_nlines; l++) \
|
goto exit; \
|
||||||
if (header[l]) \
|
|
||||||
XpmFree(header[l]); \
|
|
||||||
XpmFree(header); \
|
|
||||||
} \
|
|
||||||
return(status); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
XpmCreateDataFromXpmImage(char ***data_return, XpmImage *image, XpmInfo *info)
|
XpmCreateDataFromXpmImage(data_return, image, info)
|
||||||
|
char ***data_return;
|
||||||
|
XpmImage *image;
|
||||||
|
XpmInfo *info;
|
||||||
{
|
{
|
||||||
/* calculation variables */
|
/* calculation variables */
|
||||||
int ErrorStatus;
|
int ErrorStatus;
|
||||||
@@ -136,18 +129,29 @@ XpmCreateDataFromXpmImage(char ***data_return, XpmImage *image, XpmInfo *info)
|
|||||||
|
|
||||||
/* print the hints line */
|
/* print the hints line */
|
||||||
s = buf;
|
s = buf;
|
||||||
|
#ifndef VOID_SPRINTF
|
||||||
|
s +=
|
||||||
|
#endif
|
||||||
sprintf(s, "%d %d %d %d", image->width, image->height,
|
sprintf(s, "%d %d %d %d", image->width, image->height,
|
||||||
image->ncolors, image->cpp);
|
image->ncolors, image->cpp);
|
||||||
|
#ifdef VOID_SPRINTF
|
||||||
s += strlen(s);
|
s += strlen(s);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (info && (info->valuemask & XpmHotspot)) {
|
if (info && (info->valuemask & XpmHotspot)) {
|
||||||
|
#ifndef VOID_SPRINTF
|
||||||
|
s +=
|
||||||
|
#endif
|
||||||
sprintf(s, " %d %d", info->x_hotspot, info->y_hotspot);
|
sprintf(s, " %d %d", info->x_hotspot, info->y_hotspot);
|
||||||
|
#ifdef VOID_SPRINTF
|
||||||
s += strlen(s);
|
s += strlen(s);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (extensions)
|
if (extensions) {
|
||||||
sprintf(s, " XPMEXT");
|
strcpy(s, " XPMEXT");
|
||||||
|
s += 7;
|
||||||
l = strlen(buf) + 1;
|
}
|
||||||
|
l = s - buf + 1;
|
||||||
*header = (char *) XpmMalloc(l);
|
*header = (char *) XpmMalloc(l);
|
||||||
if (!*header)
|
if (!*header)
|
||||||
RETURN(XpmNoMemory);
|
RETURN(XpmNoMemory);
|
||||||
@@ -192,12 +196,26 @@ XpmCreateDataFromXpmImage(char ***data_return, XpmImage *image, XpmInfo *info)
|
|||||||
ext_nlines);
|
ext_nlines);
|
||||||
|
|
||||||
*data_return = data;
|
*data_return = data;
|
||||||
|
ErrorStatus = XpmSuccess;
|
||||||
|
|
||||||
RETURN(XpmSuccess);
|
/* exit point, free only locally allocated variables */
|
||||||
|
exit:
|
||||||
|
if (header) {
|
||||||
|
for (l = 0; l < header_nlines; l++)
|
||||||
|
if (header[l])
|
||||||
|
XpmFree(header[l]);
|
||||||
|
XpmFree(header);
|
||||||
|
}
|
||||||
|
return(ErrorStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
CreateColors(char **dataptr, unsigned int *data_size, XpmColor *colors, unsigned int ncolors, unsigned int cpp)
|
CreateColors(dataptr, data_size, colors, ncolors, cpp)
|
||||||
|
char **dataptr;
|
||||||
|
unsigned int *data_size;
|
||||||
|
XpmColor *colors;
|
||||||
|
unsigned int ncolors;
|
||||||
|
unsigned int cpp;
|
||||||
{
|
{
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
unsigned int a, key, l;
|
unsigned int a, key, l;
|
||||||
@@ -212,24 +230,33 @@ CreateColors(char **dataptr, unsigned int *data_size, XpmColor *colors, unsigned
|
|||||||
|
|
||||||
for (key = 1; key <= NKEYS; key++, defaults++) {
|
for (key = 1; key <= NKEYS; key++, defaults++) {
|
||||||
if (s2 = *defaults) {
|
if (s2 = *defaults) {
|
||||||
|
#ifndef VOID_SPRINTF
|
||||||
|
s +=
|
||||||
|
#endif
|
||||||
sprintf(s, "\t%s %s", xpmColorKeys[key - 1], s2);
|
sprintf(s, "\t%s %s", xpmColorKeys[key - 1], s2);
|
||||||
|
#ifdef VOID_SPRINTF
|
||||||
s += strlen(s);
|
s += strlen(s);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
l = strlen(buf) + 1;
|
l = s - buf + 1;
|
||||||
s = (char *) XpmMalloc(l);
|
s = (char *) XpmMalloc(l);
|
||||||
if (!s)
|
if (!s)
|
||||||
return (XpmNoMemory);
|
return (XpmNoMemory);
|
||||||
*data_size += l;
|
*data_size += l;
|
||||||
strcpy(s, buf);
|
*dataptr = strcpy(s, buf);
|
||||||
*dataptr = s;
|
|
||||||
}
|
}
|
||||||
return (XpmSuccess);
|
return (XpmSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CreatePixels(char **dataptr, unsigned int width, unsigned int height, unsigned int cpp,
|
CreatePixels(dataptr, width, height, cpp, pixels, colors)
|
||||||
unsigned int *pixels, XpmColor *colors)
|
char **dataptr;
|
||||||
|
unsigned int width;
|
||||||
|
unsigned int height;
|
||||||
|
unsigned int cpp;
|
||||||
|
unsigned int *pixels;
|
||||||
|
XpmColor *colors;
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
unsigned int x, y, h, offset;
|
unsigned int x, y, h, offset;
|
||||||
@@ -255,7 +282,11 @@ CreatePixels(char **dataptr, unsigned int width, unsigned int height, unsigned i
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CountExtensions(XpmExtension *ext, unsigned int num, unsigned int *ext_size, unsigned int *ext_nlines)
|
CountExtensions(ext, num, ext_size, ext_nlines)
|
||||||
|
XpmExtension *ext;
|
||||||
|
unsigned int num;
|
||||||
|
unsigned int *ext_size;
|
||||||
|
unsigned int *ext_nlines;
|
||||||
{
|
{
|
||||||
unsigned int x, y, a, size, nlines;
|
unsigned int x, y, a, size, nlines;
|
||||||
char **line;
|
char **line;
|
||||||
@@ -277,7 +308,12 @@ CountExtensions(XpmExtension *ext, unsigned int num, unsigned int *ext_size, uns
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CreateExtensions(char **dataptr, unsigned int offset, XpmExtension *ext, unsigned int num, unsigned int ext_nlines)
|
CreateExtensions(dataptr, offset, ext, num, ext_nlines)
|
||||||
|
char **dataptr;
|
||||||
|
unsigned int offset;
|
||||||
|
XpmExtension *ext;
|
||||||
|
unsigned int num;
|
||||||
|
unsigned int ext_nlines;
|
||||||
{
|
{
|
||||||
unsigned int x, y, a, b;
|
unsigned int x, y, a, b;
|
||||||
char **line;
|
char **line;
|
||||||
|
@@ -1,83 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
1539
src/xpm/create.c
1539
src/xpm/create.c
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************\
|
/*****************************************************************************\
|
||||||
* XpmCrIFrBuf.c: *
|
* CrIFrBuf.c: *
|
||||||
* *
|
* *
|
||||||
* XPM library *
|
* XPM library *
|
||||||
* Parse an Xpm buffer (file in memory) and create the image and possibly its *
|
* Parse an Xpm buffer (file in memory) and create the image and possibly its *
|
||||||
@@ -32,36 +32,47 @@
|
|||||||
* Developed by Arnaud Le Hors *
|
* Developed by Arnaud Le Hors *
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
#include "xpm34p.h"
|
#include "XpmI.h"
|
||||||
|
|
||||||
|
LFUNC(OpenBuffer, void, (char *buffer, xpmData *mdata));
|
||||||
|
|
||||||
int
|
int
|
||||||
XpmCreateImageFromBuffer(Display *display, char *buffer, XImage **image_return,
|
XpmCreateImageFromBuffer(display, buffer, image_return,
|
||||||
XImage **shapeimage_return, XpmAttributes *attributes)
|
shapeimage_return, attributes)
|
||||||
|
Display *display;
|
||||||
|
char *buffer;
|
||||||
|
XImage **image_return;
|
||||||
|
XImage **shapeimage_return;
|
||||||
|
XpmAttributes *attributes;
|
||||||
{
|
{
|
||||||
XpmImage image;
|
XpmImage image;
|
||||||
XpmInfo info;
|
XpmInfo info;
|
||||||
int ErrorStatus;
|
int ErrorStatus;
|
||||||
|
xpmData mdata;
|
||||||
|
|
||||||
/* create an XpmImage from the buffer */
|
xpmInitXpmImage(&image);
|
||||||
|
xpmInitXpmInfo(&info);
|
||||||
|
|
||||||
|
/* open buffer to read */
|
||||||
|
OpenBuffer(buffer, &mdata);
|
||||||
|
|
||||||
|
/* create the XImage from the XpmData */
|
||||||
if (attributes) {
|
if (attributes) {
|
||||||
xpmInitAttributes(attributes);
|
xpmInitAttributes(attributes);
|
||||||
xpmSetInfoMask(&info, attributes);
|
xpmSetInfoMask(&info, attributes);
|
||||||
ErrorStatus = XpmCreateXpmImageFromBuffer(buffer, &image, &info);
|
ErrorStatus = xpmParseDataAndCreate(display, &mdata,
|
||||||
|
image_return, shapeimage_return,
|
||||||
|
&image, &info, attributes);
|
||||||
} else
|
} else
|
||||||
ErrorStatus = XpmCreateXpmImageFromBuffer(buffer, &image, NULL);
|
ErrorStatus = xpmParseDataAndCreate(display, &mdata,
|
||||||
|
image_return, shapeimage_return,
|
||||||
if (ErrorStatus != XpmSuccess)
|
&image, NULL, attributes);
|
||||||
return (ErrorStatus);
|
|
||||||
|
|
||||||
/* create the related ximages */
|
|
||||||
ErrorStatus = XpmCreateImageFromXpmImage(display, &image,
|
|
||||||
image_return, shapeimage_return,
|
|
||||||
attributes);
|
|
||||||
if (attributes) {
|
if (attributes) {
|
||||||
if (ErrorStatus >= 0) /* no fatal error */
|
if (ErrorStatus >= 0) /* no fatal error */
|
||||||
xpmSetAttributes(attributes, &image, &info);
|
xpmSetAttributes(attributes, &image, &info);
|
||||||
XpmFreeXpmInfo(&info);
|
XpmFreeXpmInfo(&info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free the XpmImage */
|
/* free the XpmImage */
|
||||||
XpmFreeXpmImage(&image);
|
XpmFreeXpmImage(&image);
|
||||||
|
|
||||||
@@ -69,7 +80,10 @@ XpmCreateImageFromBuffer(Display *display, char *buffer, XImage **image_return,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
XpmCreateXpmImageFromBuffer(char *buffer, XpmImage *image, XpmInfo *info)
|
XpmCreateXpmImageFromBuffer(buffer, image, info)
|
||||||
|
char *buffer;
|
||||||
|
XpmImage *image;
|
||||||
|
XpmInfo *info;
|
||||||
{
|
{
|
||||||
xpmData mdata;
|
xpmData mdata;
|
||||||
int ErrorStatus;
|
int ErrorStatus;
|
||||||
@@ -79,12 +93,23 @@ XpmCreateXpmImageFromBuffer(char *buffer, XpmImage *image, XpmInfo *info)
|
|||||||
xpmInitXpmInfo(info);
|
xpmInitXpmInfo(info);
|
||||||
|
|
||||||
/* open buffer to read */
|
/* open buffer to read */
|
||||||
xpmOpenBuffer(buffer, &mdata);
|
OpenBuffer(buffer, &mdata);
|
||||||
|
|
||||||
/* create the XpmImage from the XpmData */
|
/* create the XpmImage from the XpmData */
|
||||||
ErrorStatus = xpmParseData(&mdata, image, info);
|
ErrorStatus = xpmParseData(&mdata, image, info);
|
||||||
|
|
||||||
xpmDataClose(&mdata);
|
|
||||||
|
|
||||||
return (ErrorStatus);
|
return (ErrorStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* open the given buffer to be read or written as an xpmData which is returned
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
OpenBuffer(buffer, mdata)
|
||||||
|
char *buffer;
|
||||||
|
xpmData *mdata;
|
||||||
|
{
|
||||||
|
mdata->type = XPMBUFFER;
|
||||||
|
mdata->cptr = buffer;
|
||||||
|
mdata->CommentLength = 0;
|
||||||
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************\
|
/*****************************************************************************\
|
||||||
* XpmCrIFrData.c: *
|
* CrIFrData.c: *
|
||||||
* *
|
* *
|
||||||
* XPM library *
|
* XPM library *
|
||||||
* Parse an Xpm array and create the image and possibly its mask *
|
* Parse an Xpm array and create the image and possibly its mask *
|
||||||
@@ -32,43 +32,58 @@
|
|||||||
* Developed by Arnaud Le Hors *
|
* Developed by Arnaud Le Hors *
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
#include "xpm34p.h"
|
#include "XpmI.h"
|
||||||
|
|
||||||
|
LFUNC(OpenArray, void, (char **data, xpmData *mdata));
|
||||||
|
|
||||||
int
|
int
|
||||||
XpmCreateImageFromData(Display *display, char **data, XImage **image_return,
|
XpmCreateImageFromData(display, data, image_return,
|
||||||
XImage **shapeimage_return, XpmAttributes *attributes)
|
shapeimage_return, attributes)
|
||||||
|
Display *display;
|
||||||
|
char **data;
|
||||||
|
XImage **image_return;
|
||||||
|
XImage **shapeimage_return;
|
||||||
|
XpmAttributes *attributes;
|
||||||
{
|
{
|
||||||
XpmImage image;
|
XpmImage image;
|
||||||
XpmInfo info;
|
XpmInfo info;
|
||||||
int ErrorStatus;
|
int ErrorStatus;
|
||||||
|
xpmData mdata;
|
||||||
|
|
||||||
|
xpmInitXpmImage(&image);
|
||||||
|
xpmInitXpmInfo(&info);
|
||||||
|
|
||||||
|
/* open data */
|
||||||
|
OpenArray(data, &mdata);
|
||||||
|
|
||||||
/* create an XpmImage from the file */
|
/* create an XpmImage from the file */
|
||||||
if (attributes) {
|
if (attributes) {
|
||||||
xpmInitAttributes(attributes);
|
xpmInitAttributes(attributes);
|
||||||
xpmSetInfoMask(&info, attributes);
|
xpmSetInfoMask(&info, attributes);
|
||||||
ErrorStatus = XpmCreateXpmImageFromData(data, &image, &info);
|
ErrorStatus = xpmParseDataAndCreate(display, &mdata,
|
||||||
|
image_return, shapeimage_return,
|
||||||
|
&image, &info, attributes);
|
||||||
} else
|
} else
|
||||||
ErrorStatus = XpmCreateXpmImageFromData(data, &image, NULL);
|
ErrorStatus = xpmParseDataAndCreate(display, &mdata,
|
||||||
|
image_return, shapeimage_return,
|
||||||
if (ErrorStatus != XpmSuccess)
|
&image, NULL, attributes);
|
||||||
return (ErrorStatus);
|
|
||||||
|
|
||||||
/* create the related ximages */
|
|
||||||
ErrorStatus = XpmCreateImageFromXpmImage(display, &image,
|
|
||||||
image_return, shapeimage_return,
|
|
||||||
attributes);
|
|
||||||
if (attributes) {
|
if (attributes) {
|
||||||
if (ErrorStatus >= 0) /* no fatal error */
|
if (ErrorStatus >= 0) /* no fatal error */
|
||||||
xpmSetAttributes(attributes, &image, &info);
|
xpmSetAttributes(attributes, &image, &info);
|
||||||
XpmFreeXpmInfo(&info);
|
XpmFreeXpmInfo(&info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* free the XpmImage */
|
||||||
XpmFreeXpmImage(&image);
|
XpmFreeXpmImage(&image);
|
||||||
|
|
||||||
return (ErrorStatus);
|
return (ErrorStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
XpmCreateXpmImageFromData(char **data, XpmImage *image, XpmInfo *info)
|
XpmCreateXpmImageFromData(data, image, info)
|
||||||
|
char **data;
|
||||||
|
XpmImage *image;
|
||||||
|
XpmInfo *info;
|
||||||
{
|
{
|
||||||
xpmData mdata;
|
xpmData mdata;
|
||||||
int ErrorStatus;
|
int ErrorStatus;
|
||||||
@@ -78,12 +93,28 @@ XpmCreateXpmImageFromData(char **data, XpmImage *image, XpmInfo *info)
|
|||||||
xpmInitXpmInfo(info);
|
xpmInitXpmInfo(info);
|
||||||
|
|
||||||
/* open data */
|
/* open data */
|
||||||
xpmOpenArray(data, &mdata);
|
OpenArray(data, &mdata);
|
||||||
|
|
||||||
/* create the XpmImage from the XpmData */
|
/* create the XpmImage from the XpmData */
|
||||||
ErrorStatus = xpmParseData(&mdata, image, info);
|
ErrorStatus = xpmParseData(&mdata, image, info);
|
||||||
|
|
||||||
xpmDataClose(&mdata);
|
|
||||||
|
|
||||||
return (ErrorStatus);
|
return (ErrorStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* open the given array to be read or written as an xpmData which is returned
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
OpenArray(data, mdata)
|
||||||
|
char **data;
|
||||||
|
xpmData *mdata;
|
||||||
|
{
|
||||||
|
mdata->type = XPMARRAY;
|
||||||
|
mdata->stream.data = data;
|
||||||
|
mdata->cptr = *data;
|
||||||
|
mdata->line = 0;
|
||||||
|
mdata->CommentLength = 0;
|
||||||
|
mdata->Bcmt = mdata->Ecmt = NULL;
|
||||||
|
mdata->Bos = mdata->Eos = '\0';
|
||||||
|
mdata->format = 0; /* this can only be Xpm 2 or 3 */
|
||||||
|
}
|
||||||
|
@@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
@@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
492
src/xpm/data.c
492
src/xpm/data.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -32,129 +32,140 @@
|
|||||||
* Developed by Arnaud Le Hors *
|
* Developed by Arnaud Le Hors *
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CXPMPROG
|
||||||
/* Official version number */
|
/* Official version number */
|
||||||
static char *RCS_Version = "$XpmVersion: 3.4b $";
|
static char *RCS_Version = "$XpmVersion: 3.4k $";
|
||||||
|
|
||||||
/* Internal version number */
|
/* Internal version number */
|
||||||
static char *RCS_Id = "$Id$";
|
static char *RCS_Id = "$Id$";
|
||||||
|
|
||||||
#include "xpm34p.h"
|
#include "XpmI.h"
|
||||||
#ifdef VMS
|
#endif
|
||||||
#include "sys$library:stat.h"
|
|
||||||
#include "sys$library:ctype.h"
|
|
||||||
#else
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#ifndef CXPMPROG
|
||||||
|
#define Getc(data, file) getc(file)
|
||||||
|
#define Ungetc(data, c, file) ungetc(c, file)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
LFUNC(ParseComment, int, (xpmData * mdata));
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ParseComment(xpmData *mdata)
|
ParseComment(data)
|
||||||
|
xpmData *data;
|
||||||
{
|
{
|
||||||
if (mdata->type == XPMBUFFER) {
|
if (data->type == XPMBUFFER) {
|
||||||
register char c;
|
register char c;
|
||||||
register unsigned int n = 0;
|
register unsigned int n = 0;
|
||||||
unsigned int notend;
|
unsigned int notend;
|
||||||
char *s, *s2;
|
char *s, *s2;
|
||||||
|
|
||||||
s = mdata->Comment;
|
s = data->Comment;
|
||||||
*s = mdata->Bcmt[0];
|
*s = data->Bcmt[0];
|
||||||
|
|
||||||
/* skip the string beginning comment */
|
/* skip the string beginning comment */
|
||||||
s2 = mdata->Bcmt;
|
s2 = data->Bcmt;
|
||||||
do {
|
do {
|
||||||
c = *mdata->cptr++;
|
c = *data->cptr++;
|
||||||
*++s = c;
|
*++s = c;
|
||||||
n++;
|
n++;
|
||||||
s2++;
|
s2++;
|
||||||
} while (c == *s2 && *s2 != '\0' && c && c != mdata->Bos);
|
} while (c == *s2 && *s2 != '\0' && c);
|
||||||
|
|
||||||
if (*s2 != '\0') {
|
if (*s2 != '\0') {
|
||||||
/* this wasn't the beginning of a comment */
|
/* this wasn't the beginning of a comment */
|
||||||
mdata->cptr -= n;
|
data->cptr -= n;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* store comment */
|
/* store comment */
|
||||||
mdata->Comment[0] = *s;
|
data->Comment[0] = *s;
|
||||||
s = mdata->Comment;
|
s = data->Comment;
|
||||||
notend = 1;
|
notend = 1;
|
||||||
n = 0;
|
n = 0;
|
||||||
while (notend) {
|
while (notend) {
|
||||||
s2 = mdata->Ecmt;
|
s2 = data->Ecmt;
|
||||||
while (*s != *s2 && c && c != mdata->Bos) {
|
while (*s != *s2 && c) {
|
||||||
c = *mdata->cptr++;
|
c = *data->cptr++;
|
||||||
|
if (n == XPMMAXCMTLEN - 1) { /* forget it */
|
||||||
|
s = data->Comment;
|
||||||
|
n = 0;
|
||||||
|
}
|
||||||
*++s = c;
|
*++s = c;
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
mdata->CommentLength = n;
|
data->CommentLength = n;
|
||||||
do {
|
do {
|
||||||
c = *mdata->cptr++;
|
c = *data->cptr++;
|
||||||
n++;
|
if (n == XPMMAXCMTLEN - 1) { /* forget it */
|
||||||
|
s = data->Comment;
|
||||||
|
n = 0;
|
||||||
|
}
|
||||||
*++s = c;
|
*++s = c;
|
||||||
|
n++;
|
||||||
s2++;
|
s2++;
|
||||||
} while (c == *s2 && *s2 != '\0' && c && c != mdata->Bos);
|
} while (c == *s2 && *s2 != '\0' && c);
|
||||||
if (*s2 == '\0') {
|
if (*s2 == '\0') {
|
||||||
/* this is the end of the comment */
|
/* this is the end of the comment */
|
||||||
notend = 0;
|
notend = 0;
|
||||||
mdata->cptr--;
|
data->cptr--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
FILE *file = mdata->stream.file;
|
FILE *file = data->stream.file;
|
||||||
register int c;
|
register int c;
|
||||||
register unsigned int n = 0, a;
|
register unsigned int n = 0, a;
|
||||||
unsigned int notend;
|
unsigned int notend;
|
||||||
char *s, *s2;
|
char *s, *s2;
|
||||||
|
|
||||||
s = mdata->Comment;
|
s = data->Comment;
|
||||||
*s = mdata->Bcmt[0];
|
*s = data->Bcmt[0];
|
||||||
|
|
||||||
/* skip the string beginning comment */
|
/* skip the string beginning comment */
|
||||||
s2 = mdata->Bcmt;
|
s2 = data->Bcmt;
|
||||||
do {
|
do {
|
||||||
c = getc(file);
|
c = Getc(data, file);
|
||||||
*++s = c;
|
*++s = c;
|
||||||
n++;
|
n++;
|
||||||
s2++;
|
s2++;
|
||||||
} while (c == *s2 && *s2 != '\0'
|
} while (c == *s2 && *s2 != '\0' && c != EOF);
|
||||||
&& c != EOF && c != mdata->Bos);
|
|
||||||
|
|
||||||
if (*s2 != '\0') {
|
if (*s2 != '\0') {
|
||||||
/* this wasn't the beginning of a comment */
|
/* this wasn't the beginning of a comment */
|
||||||
/* put characters back in the order that we got them */
|
/* put characters back in the order that we got them */
|
||||||
for (a = n; a > 0; a--, s--)
|
for (a = n; a > 0; a--, s--)
|
||||||
ungetc(*s, file);
|
Ungetc(data, *s, file);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/* store comment */
|
/* store comment */
|
||||||
mdata->Comment[0] = *s;
|
data->Comment[0] = *s;
|
||||||
s = mdata->Comment;
|
s = data->Comment;
|
||||||
notend = 1;
|
notend = 1;
|
||||||
n = 0;
|
n = 0;
|
||||||
while (notend) {
|
while (notend) {
|
||||||
s2 = mdata->Ecmt;
|
s2 = data->Ecmt;
|
||||||
while (*s != *s2 && c != EOF && c != mdata->Bos) {
|
while (*s != *s2 && c != EOF) {
|
||||||
c = getc(file);
|
c = Getc(data, file);
|
||||||
|
if (n == XPMMAXCMTLEN - 1) { /* forget it */
|
||||||
|
s = data->Comment;
|
||||||
|
n = 0;
|
||||||
|
}
|
||||||
*++s = c;
|
*++s = c;
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
mdata->CommentLength = n;
|
data->CommentLength = n;
|
||||||
do {
|
do {
|
||||||
c = getc(file);
|
c = Getc(data, file);
|
||||||
n++;
|
if (n == XPMMAXCMTLEN - 1) { /* forget it */
|
||||||
|
s = data->Comment;
|
||||||
|
n = 0;
|
||||||
|
}
|
||||||
*++s = c;
|
*++s = c;
|
||||||
|
n++;
|
||||||
s2++;
|
s2++;
|
||||||
} while (c == *s2 && *s2 != '\0'
|
} while (c == *s2 && *s2 != '\0' && c != EOF);
|
||||||
&& c != EOF && c != mdata->Bos);
|
|
||||||
if (*s2 == '\0') {
|
if (*s2 == '\0') {
|
||||||
/* this is the end of the comment */
|
/* this is the end of the comment */
|
||||||
notend = 0;
|
notend = 0;
|
||||||
ungetc(*s, file);
|
Ungetc(data, *s, file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -165,142 +176,146 @@ ParseComment(xpmData *mdata)
|
|||||||
* skip to the end of the current string and the beginning of the next one
|
* skip to the end of the current string and the beginning of the next one
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xpmNextString(xpmData *mdata)
|
xpmNextString(data)
|
||||||
|
xpmData *data;
|
||||||
{
|
{
|
||||||
if (!mdata->type)
|
if (!data->type)
|
||||||
mdata->cptr = (mdata->stream.data)[++mdata->line];
|
data->cptr = (data->stream.data)[++data->line];
|
||||||
else if (mdata->type == XPMBUFFER) {
|
else if (data->type == XPMBUFFER) {
|
||||||
register char c;
|
register char c;
|
||||||
|
|
||||||
/* get to the end of the current string */
|
/* get to the end of the current string */
|
||||||
if (mdata->Eos)
|
if (data->Eos)
|
||||||
while ((c = *mdata->cptr++) && c != mdata->Eos);
|
while ((c = *data->cptr++) && c != data->Eos);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* then get to the beginning of the next string looking for possible
|
* then get to the beginning of the next string looking for possible
|
||||||
* comment
|
* comment
|
||||||
*/
|
*/
|
||||||
if (mdata->Bos) {
|
if (data->Bos) {
|
||||||
while ((c = *mdata->cptr++) && c != mdata->Bos)
|
while ((c = *data->cptr++) && c != data->Bos)
|
||||||
if (mdata->Bcmt && c == mdata->Bcmt[0])
|
if (data->Bcmt && c == data->Bcmt[0])
|
||||||
ParseComment(mdata);
|
ParseComment(data);
|
||||||
} else if (mdata->Bcmt) { /* XPM2 natural */
|
} else if (data->Bcmt) { /* XPM2 natural */
|
||||||
while ((c = *mdata->cptr++) == mdata->Bcmt[0])
|
while ((c = *data->cptr++) == data->Bcmt[0])
|
||||||
ParseComment(mdata);
|
ParseComment(data);
|
||||||
mdata->cptr--;
|
data->cptr--;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
register int c;
|
register int c;
|
||||||
FILE *file = mdata->stream.file;
|
FILE *file = data->stream.file;
|
||||||
|
|
||||||
/* get to the end of the current string */
|
/* get to the end of the current string */
|
||||||
if (mdata->Eos)
|
if (data->Eos)
|
||||||
while ((c = getc(file)) != mdata->Eos && c != EOF);
|
while ((c = Getc(data, file)) != data->Eos && c != EOF);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* then get to the beginning of the next string looking for possible
|
* then get to the beginning of the next string looking for possible
|
||||||
* comment
|
* comment
|
||||||
*/
|
*/
|
||||||
if (mdata->Bos) {
|
if (data->Bos) {
|
||||||
while ((c = getc(file)) != mdata->Bos && c != EOF)
|
while ((c = Getc(data, file)) != data->Bos && c != EOF)
|
||||||
if (mdata->Bcmt && c == mdata->Bcmt[0])
|
if (data->Bcmt && c == data->Bcmt[0])
|
||||||
ParseComment(mdata);
|
ParseComment(data);
|
||||||
|
|
||||||
} else if (mdata->Bcmt) { /* XPM2 natural */
|
} else if (data->Bcmt) { /* XPM2 natural */
|
||||||
while ((c = getc(file)) == mdata->Bcmt[0])
|
while ((c = Getc(data, file)) == data->Bcmt[0])
|
||||||
ParseComment(mdata);
|
ParseComment(data);
|
||||||
ungetc(c, file);
|
Ungetc(data, c, file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* skip whitespace and compute the following unsigned int,
|
|
||||||
* returns 1 if one is found and 0 if not
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
xpmNextUI(xpmData *mdata, unsigned int *ui_return)
|
|
||||||
{
|
|
||||||
char buf[BUFSIZ];
|
|
||||||
int l;
|
|
||||||
|
|
||||||
l = xpmNextWord(mdata, buf, BUFSIZ);
|
|
||||||
return atoui(buf, l, ui_return);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* skip whitespace and return the following word
|
* skip whitespace and return the following word
|
||||||
*/
|
*/
|
||||||
unsigned int
|
unsigned int
|
||||||
xpmNextWord(xpmData *mdata, char *buf, unsigned int buflen)
|
xpmNextWord(data, buf, buflen)
|
||||||
|
xpmData *data;
|
||||||
|
char *buf;
|
||||||
|
unsigned int buflen;
|
||||||
{
|
{
|
||||||
register unsigned int n = 0;
|
register unsigned int n = 0;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
if (!mdata->type || mdata->type == XPMBUFFER) {
|
if (!data->type || data->type == XPMBUFFER) {
|
||||||
while (isspace(c = *mdata->cptr) && c != mdata->Eos)
|
while (isspace(c = *data->cptr) && c != data->Eos)
|
||||||
mdata->cptr++;
|
data->cptr++;
|
||||||
do {
|
do {
|
||||||
c = *mdata->cptr++;
|
c = *data->cptr++;
|
||||||
*buf++ = c;
|
*buf++ = c;
|
||||||
n++;
|
n++;
|
||||||
} while (!isspace(c) && c != mdata->Eos && n < buflen);
|
} while (!isspace(c) && c != data->Eos && n < buflen);
|
||||||
n--;
|
n--;
|
||||||
mdata->cptr--;
|
data->cptr--;
|
||||||
} else {
|
} else {
|
||||||
FILE *file = mdata->stream.file;
|
FILE *file = data->stream.file;
|
||||||
|
|
||||||
while ((c = getc(file)) != EOF && isspace(c) && c != mdata->Eos);
|
while ((c = Getc(data, file)) != EOF && isspace(c) && c != data->Eos);
|
||||||
while (!isspace(c) && c != mdata->Eos && c != EOF && n < buflen) {
|
while (!isspace(c) && c != data->Eos && c != EOF && n < buflen) {
|
||||||
*buf++ = c;
|
*buf++ = c;
|
||||||
n++;
|
n++;
|
||||||
c = getc(file);
|
c = Getc(data, file);
|
||||||
}
|
}
|
||||||
ungetc(c, file);
|
Ungetc(data, c, file);
|
||||||
}
|
}
|
||||||
return (n);
|
return (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* skip whitespace and compute the following unsigned int,
|
||||||
|
* returns 1 if one is found and 0 if not
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xpmNextUI(data, ui_return)
|
||||||
|
xpmData *data;
|
||||||
|
unsigned int *ui_return;
|
||||||
|
{
|
||||||
|
char buf[BUFSIZ];
|
||||||
|
int l;
|
||||||
|
|
||||||
|
l = xpmNextWord(data, buf, BUFSIZ);
|
||||||
|
return xpmatoui(buf, l, ui_return);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* return end of string - WARNING: malloc!
|
* return end of string - WARNING: malloc!
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xpmGetString(xpmData *mdata, char **sptr, unsigned int *l)
|
xpmGetString(data, sptr, l)
|
||||||
|
xpmData *data;
|
||||||
|
char **sptr;
|
||||||
|
unsigned int *l;
|
||||||
{
|
{
|
||||||
unsigned int i, n = 0;
|
unsigned int i, n = 0;
|
||||||
int c;
|
int c;
|
||||||
char *p, *q, buf[BUFSIZ];
|
char *p = NULL, *q, buf[BUFSIZ];
|
||||||
|
|
||||||
if (!mdata->type || mdata->type == XPMBUFFER) {
|
if (!data->type || data->type == XPMBUFFER) {
|
||||||
if (mdata->cptr) {
|
if (data->cptr) {
|
||||||
char *start;
|
char *start = data->cptr;
|
||||||
|
while ((c = *data->cptr) && c != data->Eos)
|
||||||
while (isspace(c = *mdata->cptr) && c != mdata->Eos)
|
data->cptr++;
|
||||||
mdata->cptr++;
|
n = data->cptr - start + 1;
|
||||||
start = mdata->cptr;
|
|
||||||
while ((c = *mdata->cptr) && c != mdata->Eos)
|
|
||||||
mdata->cptr++;
|
|
||||||
n = mdata->cptr - start + 1;
|
|
||||||
p = (char *) XpmMalloc(n);
|
p = (char *) XpmMalloc(n);
|
||||||
if (!p)
|
if (!p)
|
||||||
return (XpmNoMemory);
|
return (XpmNoMemory);
|
||||||
strncpy(p, start, n);
|
strncpy(p, start, n);
|
||||||
if (mdata->type) /* XPMBUFFER */
|
if (data->type) /* XPMBUFFER */
|
||||||
p[n - 1] = '\0';
|
p[n - 1] = '\0';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
FILE *file = mdata->stream.file;
|
FILE *file = data->stream.file;
|
||||||
|
|
||||||
while ((c = getc(file)) != EOF && isspace(c) && c != mdata->Eos);
|
if ((c = Getc(data, file)) == EOF)
|
||||||
if (c == EOF)
|
|
||||||
return (XpmFileInvalid);
|
return (XpmFileInvalid);
|
||||||
p = NULL;
|
|
||||||
i = 0;
|
i = 0;
|
||||||
q = buf;
|
q = buf;
|
||||||
p = (char *) XpmMalloc(1);
|
p = (char *) XpmMalloc(1);
|
||||||
while (c != mdata->Eos && c != EOF) {
|
while (c != data->Eos && c != EOF) {
|
||||||
if (i == BUFSIZ) {
|
if (i == BUFSIZ) {
|
||||||
/* get to the end of the buffer */
|
/* get to the end of the buffer */
|
||||||
/* malloc needed memory */
|
/* malloc needed memory */
|
||||||
@@ -319,7 +334,7 @@ xpmGetString(xpmData *mdata, char **sptr, unsigned int *l)
|
|||||||
}
|
}
|
||||||
*q++ = c;
|
*q++ = c;
|
||||||
i++;
|
i++;
|
||||||
c = getc(file);
|
c = Getc(data, file);
|
||||||
}
|
}
|
||||||
if (c == EOF) {
|
if (c == EOF) {
|
||||||
XpmFree(p);
|
XpmFree(p);
|
||||||
@@ -342,7 +357,7 @@ xpmGetString(xpmData *mdata, char **sptr, unsigned int *l)
|
|||||||
*p = '\0';
|
*p = '\0';
|
||||||
n = 1;
|
n = 1;
|
||||||
}
|
}
|
||||||
ungetc(c, file);
|
Ungetc(data, c, file);
|
||||||
}
|
}
|
||||||
*sptr = p;
|
*sptr = p;
|
||||||
*l = n;
|
*l = n;
|
||||||
@@ -353,187 +368,22 @@ xpmGetString(xpmData *mdata, char **sptr, unsigned int *l)
|
|||||||
* get the current comment line
|
* get the current comment line
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xpmGetCmt(xpmData *mdata, char **cmt)
|
xpmGetCmt(data, cmt)
|
||||||
|
xpmData *data;
|
||||||
|
char **cmt;
|
||||||
{
|
{
|
||||||
if (!mdata->type)
|
if (!data->type)
|
||||||
*cmt = NULL;
|
*cmt = NULL;
|
||||||
else if (mdata->CommentLength) {
|
else if (data->CommentLength) {
|
||||||
*cmt = (char *) XpmMalloc(mdata->CommentLength + 1);
|
*cmt = (char *) XpmMalloc(data->CommentLength + 1);
|
||||||
strncpy(*cmt, mdata->Comment, mdata->CommentLength);
|
strncpy(*cmt, data->Comment, data->CommentLength);
|
||||||
(*cmt)[mdata->CommentLength] = '\0';
|
(*cmt)[data->CommentLength] = '\0';
|
||||||
mdata->CommentLength = 0;
|
data->CommentLength = 0;
|
||||||
} else
|
} else
|
||||||
*cmt = NULL;
|
*cmt = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* open the given file to be read as an xpmData which is returned.
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
xpmReadFile(char *filename, xpmData *mdata)
|
|
||||||
{
|
|
||||||
#ifdef ZPIPE
|
|
||||||
char *compressfile, buf[BUFSIZ];
|
|
||||||
struct stat status;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!filename) {
|
|
||||||
mdata->stream.file = (stdin);
|
|
||||||
mdata->type = XPMFILE;
|
|
||||||
} else {
|
|
||||||
#ifdef ZPIPE
|
|
||||||
if (((int) strlen(filename) > 2) &&
|
|
||||||
!strcmp(".Z", filename + (strlen(filename) - 2))) {
|
|
||||||
mdata->type = XPMPIPE;
|
|
||||||
sprintf(buf, "uncompress -c %s", filename);
|
|
||||||
if (!(mdata->stream.file = popen(buf, "r")))
|
|
||||||
return (XpmOpenFailed);
|
|
||||||
|
|
||||||
} else if (((int) strlen(filename) > 3) &&
|
|
||||||
!strcmp(".gz", filename + (strlen(filename) - 3))) {
|
|
||||||
mdata->type = XPMPIPE;
|
|
||||||
sprintf(buf, "gunzip -qc %s", filename);
|
|
||||||
if (!(mdata->stream.file = popen(buf, "r")))
|
|
||||||
return (XpmOpenFailed);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (!(compressfile = (char *) XpmMalloc(strlen(filename) + 4)))
|
|
||||||
return (XpmNoMemory);
|
|
||||||
|
|
||||||
strcpy(compressfile, filename);
|
|
||||||
strcat(compressfile, ".Z");
|
|
||||||
if (!stat(compressfile, &status)) {
|
|
||||||
sprintf(buf, "uncompress -c %s", compressfile);
|
|
||||||
if (!(mdata->stream.file = popen(buf, "r"))) {
|
|
||||||
XpmFree(compressfile);
|
|
||||||
return (XpmOpenFailed);
|
|
||||||
}
|
|
||||||
mdata->type = XPMPIPE;
|
|
||||||
} else {
|
|
||||||
strcpy(compressfile, filename);
|
|
||||||
strcat(compressfile, ".gz");
|
|
||||||
if (!stat(compressfile, &status)) {
|
|
||||||
sprintf(buf, "gunzip -c %s", compressfile);
|
|
||||||
if (!(mdata->stream.file = popen(buf, "r"))) {
|
|
||||||
XpmFree(compressfile);
|
|
||||||
return (XpmOpenFailed);
|
|
||||||
}
|
|
||||||
mdata->type = XPMPIPE;
|
|
||||||
} else {
|
|
||||||
#endif
|
|
||||||
if (!(mdata->stream.file = fopen(filename, "r"))) {
|
|
||||||
#ifdef ZPIPE
|
|
||||||
XpmFree(compressfile);
|
|
||||||
#endif
|
|
||||||
return (XpmOpenFailed);
|
|
||||||
}
|
|
||||||
mdata->type = XPMFILE;
|
|
||||||
#ifdef ZPIPE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
XpmFree(compressfile);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
mdata->CommentLength = 0;
|
|
||||||
return (XpmSuccess);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* open the given file to be written as an xpmData which is returned
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
xpmWriteFile(char *filename, xpmData *mdata)
|
|
||||||
{
|
|
||||||
#ifdef ZPIPE
|
|
||||||
char buf[BUFSIZ];
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!filename) {
|
|
||||||
mdata->stream.file = (stdout);
|
|
||||||
mdata->type = XPMFILE;
|
|
||||||
} else {
|
|
||||||
#ifdef ZPIPE
|
|
||||||
if ((int) strlen(filename) > 2
|
|
||||||
&& !strcmp(".Z", filename + (strlen(filename) - 2))) {
|
|
||||||
sprintf(buf, "compress > %s", filename);
|
|
||||||
if (!(mdata->stream.file = popen(buf, "w")))
|
|
||||||
return (XpmOpenFailed);
|
|
||||||
|
|
||||||
mdata->type = XPMPIPE;
|
|
||||||
} else if ((int) strlen(filename) > 3
|
|
||||||
&& !strcmp(".gz", filename + (strlen(filename) - 3))) {
|
|
||||||
sprintf(buf, "gzip -q > %s", filename);
|
|
||||||
if (!(mdata->stream.file = popen(buf, "w")))
|
|
||||||
return (XpmOpenFailed);
|
|
||||||
|
|
||||||
mdata->type = XPMPIPE;
|
|
||||||
} else {
|
|
||||||
#endif
|
|
||||||
if (!(mdata->stream.file = fopen(filename, "w")))
|
|
||||||
return (XpmOpenFailed);
|
|
||||||
|
|
||||||
mdata->type = XPMFILE;
|
|
||||||
#ifdef ZPIPE
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return (XpmSuccess);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* open the given array to be read or written as an xpmData which is returned
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xpmOpenArray(char **data, xpmData *mdata)
|
|
||||||
{
|
|
||||||
mdata->type = XPMARRAY;
|
|
||||||
mdata->stream.data = data;
|
|
||||||
mdata->cptr = *data;
|
|
||||||
mdata->line = 0;
|
|
||||||
mdata->CommentLength = 0;
|
|
||||||
mdata->Bcmt = mdata->Ecmt = NULL;
|
|
||||||
mdata->Bos = mdata->Eos = '\0';
|
|
||||||
mdata->format = 0; /* this can only be Xpm 2 or 3 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* open the given buffer to be read or written as an xpmData which is returned
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xpmOpenBuffer(char *buffer, xpmData *mdata)
|
|
||||||
{
|
|
||||||
mdata->type = XPMBUFFER;
|
|
||||||
mdata->cptr = buffer;
|
|
||||||
mdata->CommentLength = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* close the file related to the xpmData if any
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
xpmDataClose(xpmData *mdata)
|
|
||||||
{
|
|
||||||
switch (mdata->type) {
|
|
||||||
case XPMARRAY:
|
|
||||||
case XPMBUFFER:
|
|
||||||
break;
|
|
||||||
case XPMFILE:
|
|
||||||
if (mdata->stream.file != (stdout) && mdata->stream.file != (stdin))
|
|
||||||
fclose(mdata->stream.file);
|
|
||||||
break;
|
|
||||||
#ifdef ZPIPE
|
|
||||||
case XPMPIPE:
|
|
||||||
pclose(mdata->stream.file);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
xpmDataType xpmDataTypes[] =
|
xpmDataType xpmDataTypes[] =
|
||||||
{
|
{
|
||||||
"", "!", "\n", '\0', '\n', "", "", "", "", /* Natural type */
|
"", "!", "\n", '\0', '\n', "", "", "", "", /* Natural type */
|
||||||
@@ -550,28 +400,30 @@ xpmDataType xpmDataTypes[] =
|
|||||||
* parse xpm header
|
* parse xpm header
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xpmParseHeader(xpmData *mdata)
|
xpmParseHeader(data)
|
||||||
|
xpmData *data;
|
||||||
{
|
{
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
int l, n = 0;
|
int l, n = 0;
|
||||||
|
|
||||||
if (mdata->type) {
|
if (data->type) {
|
||||||
mdata->Bos = '\0';
|
data->Bos = '\0';
|
||||||
mdata->Eos = '\n';
|
data->Eos = '\n';
|
||||||
mdata->Bcmt = mdata->Ecmt = NULL;
|
data->Bcmt = data->Ecmt = NULL;
|
||||||
l = xpmNextWord(mdata, buf, BUFSIZ);
|
l = xpmNextWord(data, buf, BUFSIZ);
|
||||||
if (l == 7 && !strncmp("#define", buf, 7)) {
|
if (l == 7 && !strncmp("#define", buf, 7)) {
|
||||||
/* this maybe an XPM 1 file */
|
/* this maybe an XPM 1 file */
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
|
||||||
l = xpmNextWord(mdata, buf, BUFSIZ);
|
l = xpmNextWord(data, buf, BUFSIZ);
|
||||||
if (!l)
|
if (!l)
|
||||||
return (XpmFileInvalid);
|
return (XpmFileInvalid);
|
||||||
ptr = strchr(buf, '_');
|
buf[l] = '\0';
|
||||||
|
ptr = rindex(buf, '_');
|
||||||
if (!ptr || strncmp("_format", ptr, l - (ptr - buf)))
|
if (!ptr || strncmp("_format", ptr, l - (ptr - buf)))
|
||||||
return XpmFileInvalid;
|
return XpmFileInvalid;
|
||||||
/* this is definitely an XPM 1 file */
|
/* this is definitely an XPM 1 file */
|
||||||
mdata->format = 1;
|
data->format = 1;
|
||||||
n = 1; /* handle XPM1 as mainly XPM2 C */
|
n = 1; /* handle XPM1 as mainly XPM2 C */
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -579,14 +431,14 @@ xpmParseHeader(xpmData *mdata)
|
|||||||
* skip the first word, get the second one, and see if this is
|
* skip the first word, get the second one, and see if this is
|
||||||
* XPM 2 or 3
|
* XPM 2 or 3
|
||||||
*/
|
*/
|
||||||
l = xpmNextWord(mdata, buf, BUFSIZ);
|
l = xpmNextWord(data, buf, BUFSIZ);
|
||||||
if ((l == 3 && !strncmp("XPM", buf, 3)) ||
|
if ((l == 3 && !strncmp("XPM", buf, 3)) ||
|
||||||
(l == 4 && !strncmp("XPM2", buf, 4))) {
|
(l == 4 && !strncmp("XPM2", buf, 4))) {
|
||||||
if (l == 3)
|
if (l == 3)
|
||||||
n = 1; /* handle XPM as XPM2 C */
|
n = 1; /* handle XPM as XPM2 C */
|
||||||
else {
|
else {
|
||||||
/* get the type key word */
|
/* get the type key word */
|
||||||
l = xpmNextWord(mdata, buf, BUFSIZ);
|
l = xpmNextWord(data, buf, BUFSIZ);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* get infos about this type
|
* get infos about this type
|
||||||
@@ -595,29 +447,29 @@ xpmParseHeader(xpmData *mdata)
|
|||||||
&& strncmp(xpmDataTypes[n].type, buf, l))
|
&& strncmp(xpmDataTypes[n].type, buf, l))
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
mdata->format = 0;
|
data->format = 0;
|
||||||
} else
|
} else
|
||||||
/* nope this is not an XPM file */
|
/* nope this is not an XPM file */
|
||||||
return XpmFileInvalid;
|
return XpmFileInvalid;
|
||||||
}
|
}
|
||||||
if (xpmDataTypes[n].type) {
|
if (xpmDataTypes[n].type) {
|
||||||
if (n == 0) { /* natural type */
|
if (n == 0) { /* natural type */
|
||||||
mdata->Bcmt = xpmDataTypes[n].Bcmt;
|
data->Bcmt = xpmDataTypes[n].Bcmt;
|
||||||
mdata->Ecmt = xpmDataTypes[n].Ecmt;
|
data->Ecmt = xpmDataTypes[n].Ecmt;
|
||||||
xpmNextString(mdata); /* skip the end of the headerline */
|
xpmNextString(data); /* skip the end of the headerline */
|
||||||
mdata->Bos = xpmDataTypes[n].Bos;
|
data->Bos = xpmDataTypes[n].Bos;
|
||||||
mdata->Eos = xpmDataTypes[n].Eos;
|
data->Eos = xpmDataTypes[n].Eos;
|
||||||
} else {
|
} else {
|
||||||
mdata->Bcmt = xpmDataTypes[n].Bcmt;
|
data->Bcmt = xpmDataTypes[n].Bcmt;
|
||||||
mdata->Ecmt = xpmDataTypes[n].Ecmt;
|
data->Ecmt = xpmDataTypes[n].Ecmt;
|
||||||
if (!mdata->format) { /* XPM 2 or 3 */
|
if (!data->format) { /* XPM 2 or 3 */
|
||||||
mdata->Bos = xpmDataTypes[n].Bos;
|
data->Bos = xpmDataTypes[n].Bos;
|
||||||
mdata->Eos = '\0';
|
data->Eos = '\0';
|
||||||
/* get to the beginning of the first string */
|
/* get to the beginning of the first string */
|
||||||
xpmNextString(mdata);
|
xpmNextString(data);
|
||||||
mdata->Eos = xpmDataTypes[n].Eos;
|
data->Eos = xpmDataTypes[n].Eos;
|
||||||
} else /* XPM 1 skip end of line */
|
} else /* XPM 1 skip end of line */
|
||||||
xpmNextString(mdata);
|
xpmNextString(data);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
/* we don't know about that type of XPM file... */
|
/* we don't know about that type of XPM file... */
|
||||||
|
@@ -1,31 +1,46 @@
|
|||||||
CHANGES
|
CHANGES
|
||||||
COPYRIGHT
|
COPYRIGHT
|
||||||
|
FAQ.html
|
||||||
FILES
|
FILES
|
||||||
Imakefile
|
Imakefile
|
||||||
Makefile.noXtree
|
Makefile.noX
|
||||||
README
|
README.html
|
||||||
|
README.AMIGA
|
||||||
README.MSW
|
README.MSW
|
||||||
namecvt
|
namecvt
|
||||||
lib
|
lib
|
||||||
lib/Imakefile
|
lib/Imakefile
|
||||||
lib/Makefile.noXtree
|
lib/Makefile.noX
|
||||||
lib/XpmCrBufFrI.c
|
lib/Makefile.AmigaGCC
|
||||||
lib/XpmCrBufFrP.c
|
lib/Smakefile
|
||||||
lib/XpmCrDataFrI.c
|
lib/Attrib.c
|
||||||
lib/XpmCrDataFrP.c
|
lib/CrBufFrI.c
|
||||||
lib/XpmCrIFrBuf.c
|
lib/CrBufFrP.c
|
||||||
lib/XpmCrIFrData.c
|
lib/CrDatFrI.c
|
||||||
lib/XpmCrPFrBuf.c
|
lib/CrDatFrP.c
|
||||||
lib/XpmCrPFrData.c
|
lib/CrIFrBuf.c
|
||||||
lib/XpmRdFToData.c
|
lib/CrIFrDat.c
|
||||||
lib/XpmRdFToI.c
|
lib/CrIFrP.c
|
||||||
lib/XpmRdFToP.c
|
lib/CrPFrBuf.c
|
||||||
lib/XpmWrFFrData.c
|
lib/CrPFrDat.c
|
||||||
lib/XpmWrFFrI.c
|
lib/CrPFrI.c
|
||||||
lib/XpmWrFFrP.c
|
lib/Image.c
|
||||||
|
lib/Info.c
|
||||||
|
lib/RdFToBuf.c
|
||||||
|
lib/RdFToDat.c
|
||||||
|
lib/RdFToI.c
|
||||||
|
lib/RdFToP.c
|
||||||
|
lib/WrFFrBuf.c
|
||||||
|
lib/WrFFrDat.c
|
||||||
|
lib/WrFFrI.c
|
||||||
|
lib/WrFFrP.c
|
||||||
|
lib/amigax.h
|
||||||
|
lib/amigax.c
|
||||||
lib/create.c
|
lib/create.c
|
||||||
lib/data.c
|
lib/data.c
|
||||||
lib/hashtable.c
|
lib/descrip.mms
|
||||||
|
lib/hashtab.c
|
||||||
|
lib/make.com
|
||||||
lib/misc.c
|
lib/misc.c
|
||||||
lib/parse.c
|
lib/parse.c
|
||||||
lib/rgb.c
|
lib/rgb.c
|
||||||
@@ -34,14 +49,20 @@ lib/scan.c
|
|||||||
lib/simx.h
|
lib/simx.h
|
||||||
lib/simx.c
|
lib/simx.c
|
||||||
lib/xpm.h
|
lib/xpm.h
|
||||||
lib/xpmP.h
|
lib/XpmI.h
|
||||||
|
lib/Xpm-def.cpp
|
||||||
doc
|
doc
|
||||||
doc/xpm.ps
|
doc/xpm.PS
|
||||||
sxpm
|
sxpm
|
||||||
sxpm/Imakefile
|
sxpm/Imakefile
|
||||||
sxpm/Makefile.noXtree
|
sxpm/Makefile.noX
|
||||||
sxpm/plaid.xpm
|
sxpm/plaid.xpm
|
||||||
sxpm/plaid_ext.xpm
|
sxpm/plaid_ext.xpm
|
||||||
sxpm/plaid_mask.xpm
|
sxpm/plaid_mask.xpm
|
||||||
sxpm/sxpm.c
|
sxpm/sxpm.c
|
||||||
sxpm/sxpm.man
|
sxpm/sxpm.man
|
||||||
|
cxpm
|
||||||
|
cxpm/Imakefile
|
||||||
|
cxpm/Makefile.noX
|
||||||
|
cxpm/cxpm.c
|
||||||
|
cxpm/cxpm.man
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************\
|
/*****************************************************************************\
|
||||||
* hashtable.c: *
|
* hashtab.c: *
|
||||||
* *
|
* *
|
||||||
* XPM library *
|
* XPM library *
|
||||||
* *
|
* *
|
||||||
@@ -33,15 +33,15 @@
|
|||||||
* *
|
* *
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
#include "xpm34p.h"
|
#include "XpmI.h"
|
||||||
|
|
||||||
LFUNC(AtomMake, xpmHashAtom, (char *name, void *data));
|
LFUNC(AtomMake, xpmHashAtom, (char *name, void *data));
|
||||||
LFUNC(HashTableGrows, int, (xpmHashTable * table));
|
LFUNC(HashTableGrows, int, (xpmHashTable * table));
|
||||||
|
|
||||||
static xpmHashAtom
|
static xpmHashAtom
|
||||||
AtomMake(char *name, void *data) /* makes an atom */
|
AtomMake(name, data) /* makes an atom */
|
||||||
/* char *name; */ /* WARNING: is just pointed to */
|
char *name; /* WARNING: is just pointed to */
|
||||||
/* void *data; */
|
void *data;
|
||||||
{
|
{
|
||||||
xpmHashAtom object = (xpmHashAtom) XpmMalloc(sizeof(struct _xpmHashAtom));
|
xpmHashAtom object = (xpmHashAtom) XpmMalloc(sizeof(struct _xpmHashAtom));
|
||||||
|
|
||||||
@@ -104,7 +104,9 @@ AtomMake(char *name, void *data) /* makes an atom */
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
xpmHashAtom *
|
xpmHashAtom *
|
||||||
xpmHashSlot(xpmHashTable *table, char *s)
|
xpmHashSlot(table, s)
|
||||||
|
xpmHashTable *table;
|
||||||
|
char *s;
|
||||||
{
|
{
|
||||||
xpmHashAtom *atomTable = table->atomTable;
|
xpmHashAtom *atomTable = table->atomTable;
|
||||||
unsigned int hash;
|
unsigned int hash;
|
||||||
@@ -129,7 +131,8 @@ xpmHashSlot(xpmHashTable *table, char *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
HashTableGrows(xpmHashTable *table)
|
HashTableGrows(table)
|
||||||
|
xpmHashTable *table;
|
||||||
{
|
{
|
||||||
xpmHashAtom *atomTable = table->atomTable;
|
xpmHashAtom *atomTable = table->atomTable;
|
||||||
int size = table->size;
|
int size = table->size;
|
||||||
@@ -163,7 +166,10 @@ HashTableGrows(xpmHashTable *table)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
xpmHashIntern(xpmHashTable *table, char *tag, void *data)
|
xpmHashIntern(table, tag, data)
|
||||||
|
xpmHashTable *table;
|
||||||
|
char *tag;
|
||||||
|
void *data;
|
||||||
{
|
{
|
||||||
xpmHashAtom *slot;
|
xpmHashAtom *slot;
|
||||||
|
|
||||||
@@ -189,7 +195,8 @@ xpmHashIntern(xpmHashTable *table, char *tag, void *data)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
xpmHashTableInit(xpmHashTable *table)
|
xpmHashTableInit(table)
|
||||||
|
xpmHashTable *table;
|
||||||
{
|
{
|
||||||
xpmHashAtom *p;
|
xpmHashAtom *p;
|
||||||
xpmHashAtom *atomTable;
|
xpmHashAtom *atomTable;
|
||||||
@@ -211,11 +218,14 @@ xpmHashTableInit(xpmHashTable *table)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
xpmHashTableFree(xpmHashTable *table)
|
xpmHashTableFree(table)
|
||||||
|
xpmHashTable *table;
|
||||||
{
|
{
|
||||||
xpmHashAtom *p;
|
xpmHashAtom *p;
|
||||||
xpmHashAtom *atomTable = table->atomTable;
|
xpmHashAtom *atomTable = table->atomTable;
|
||||||
|
|
||||||
|
if (!atomTable)
|
||||||
|
return;
|
||||||
for (p = atomTable + table->size; p > atomTable;)
|
for (p = atomTable + table->size; p > atomTable;)
|
||||||
if (*--p)
|
if (*--p)
|
||||||
XpmFree(*p);
|
XpmFree(*p);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -24,49 +24,38 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************\
|
/*****************************************************************************\
|
||||||
* XpmRdFToP.c: *
|
* Image.c: *
|
||||||
* *
|
* *
|
||||||
* XPM library *
|
* XPM library *
|
||||||
* Parse an XPM file and create the pixmap and possibly its mask *
|
* Functions to init and free the XpmImage structure. *
|
||||||
* *
|
* *
|
||||||
* Developed by Arnaud Le Hors *
|
* Developed by Arnaud Le Hors *
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
#ifndef FOR_MSW
|
#include "XpmI.h"
|
||||||
|
|
||||||
#include "xpm34p.h"
|
/*
|
||||||
|
* Init returned data to free safely later on
|
||||||
int
|
*/
|
||||||
XpmReadFileToPixmap(Display *display, Drawable d, char *filename, Pixmap *pixmap_return,
|
void
|
||||||
Pixmap *shapemask_return, XpmAttributes *attributes)
|
xpmInitXpmImage(image)
|
||||||
|
XpmImage *image;
|
||||||
{
|
{
|
||||||
XImage *ximage, *shapeimage;
|
image->ncolors = 0;
|
||||||
int ErrorStatus;
|
image->colorTable = NULL;
|
||||||
|
image->data = NULL;
|
||||||
/* initialize return values */
|
}
|
||||||
if (pixmap_return)
|
|
||||||
*pixmap_return = 0;
|
/*
|
||||||
if (shapemask_return)
|
* Free the XpmImage data which have been allocated
|
||||||
*shapemask_return = 0;
|
*/
|
||||||
|
void
|
||||||
/* create the images */
|
XpmFreeXpmImage(image)
|
||||||
ErrorStatus = XpmReadFileToImage(display, filename,
|
XpmImage *image;
|
||||||
(pixmap_return ? &ximage : NULL),
|
{
|
||||||
(shapemask_return ? &shapeimage : NULL),
|
if (image->colorTable)
|
||||||
attributes);
|
xpmFreeColorTable(image->colorTable, image->ncolors);
|
||||||
|
if (image->data)
|
||||||
if (ErrorStatus < 0) /* fatal error */
|
XpmFree(image->data);
|
||||||
return (ErrorStatus);
|
image->data = NULL;
|
||||||
|
|
||||||
/* 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
|
|
124
src/xpm/info.c
Normal file
124
src/xpm/info.c
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to
|
||||||
|
* deal in the Software without restriction, including without limitation the
|
||||||
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
* sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||||
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*
|
||||||
|
* Except as contained in this notice, the name of GROUPE BULL shall not be
|
||||||
|
* used in advertising or otherwise to promote the sale, use or other dealings
|
||||||
|
* in this Software without prior written authorization from GROUPE BULL.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*****************************************************************************\
|
||||||
|
* Info.c: *
|
||||||
|
* *
|
||||||
|
* XPM library *
|
||||||
|
* Functions related to the XpmInfo structure. *
|
||||||
|
* *
|
||||||
|
* Developed by Arnaud Le Hors *
|
||||||
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
#include "XpmI.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Init returned data to free safely later on
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xpmInitXpmInfo(info)
|
||||||
|
XpmInfo *info;
|
||||||
|
{
|
||||||
|
if (info) {
|
||||||
|
info->hints_cmt = NULL;
|
||||||
|
info->colors_cmt = NULL;
|
||||||
|
info->pixels_cmt = NULL;
|
||||||
|
info->extensions = NULL;
|
||||||
|
info->nextensions = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Free the XpmInfo data which have been allocated
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
XpmFreeXpmInfo(info)
|
||||||
|
XpmInfo *info;
|
||||||
|
{
|
||||||
|
if (info) {
|
||||||
|
if (info->valuemask & XpmComments) {
|
||||||
|
if (info->hints_cmt) {
|
||||||
|
XpmFree(info->hints_cmt);
|
||||||
|
info->hints_cmt = NULL;
|
||||||
|
}
|
||||||
|
if (info->colors_cmt) {
|
||||||
|
XpmFree(info->colors_cmt);
|
||||||
|
info->colors_cmt = NULL;
|
||||||
|
}
|
||||||
|
if (info->pixels_cmt) {
|
||||||
|
XpmFree(info->pixels_cmt);
|
||||||
|
info->pixels_cmt = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (info->valuemask & XpmReturnExtensions && info->nextensions) {
|
||||||
|
XpmFreeExtensions(info->extensions, info->nextensions);
|
||||||
|
info->extensions = NULL;
|
||||||
|
info->nextensions = 0;
|
||||||
|
}
|
||||||
|
info->valuemask = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the XpmInfo valuemask to retrieve required info
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xpmSetInfoMask(info, attributes)
|
||||||
|
XpmInfo *info;
|
||||||
|
XpmAttributes *attributes;
|
||||||
|
{
|
||||||
|
info->valuemask = 0;
|
||||||
|
if (attributes->valuemask & XpmReturnInfos)
|
||||||
|
info->valuemask |= XpmReturnComments;
|
||||||
|
if (attributes->valuemask & XpmReturnExtensions)
|
||||||
|
info->valuemask |= XpmReturnExtensions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Fill in the XpmInfo with the XpmAttributes
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xpmSetInfo(info, attributes)
|
||||||
|
XpmInfo *info;
|
||||||
|
XpmAttributes *attributes;
|
||||||
|
{
|
||||||
|
info->valuemask = 0;
|
||||||
|
if (attributes->valuemask & XpmInfos) {
|
||||||
|
info->valuemask |= XpmComments | XpmColorTable;
|
||||||
|
info->hints_cmt = attributes->hints_cmt;
|
||||||
|
info->colors_cmt = attributes->colors_cmt;
|
||||||
|
info->pixels_cmt = attributes->pixels_cmt;
|
||||||
|
}
|
||||||
|
if (attributes->valuemask & XpmExtensions) {
|
||||||
|
info->valuemask |= XpmExtensions;
|
||||||
|
info->extensions = attributes->extensions;
|
||||||
|
info->nextensions = attributes->nextensions;
|
||||||
|
}
|
||||||
|
if (attributes->valuemask & XpmHotspot) {
|
||||||
|
info->valuemask |= XpmHotspot;
|
||||||
|
info->x_hotspot = attributes->x_hotspot;
|
||||||
|
info->y_hotspot = attributes->y_hotspot;
|
||||||
|
}
|
||||||
|
}
|
@@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
LIBTARGET=$(WXDIR)\lib\xpm.lib
|
LIBTARGET=$(WXDIR)\lib\xpm.lib
|
||||||
|
|
||||||
OBJECTS = crbuffri.obj crdatfri.obj create.obj crifrbuf.obj crifrdat.obj\
|
OBJECTS = attrib.obj crbuffri.obj crdatfri.obj create.obj crifrbuf.obj crifrdat.obj\
|
||||||
data.obj hashtab.obj misc.obj parse.obj rdftodat.obj rdftoi.obj\
|
data.obj image.obj info.obj hashtab.obj misc.obj parse.obj\
|
||||||
rgb.obj scan.obj simx.obj wrffrdat.obj wrffrp.obj wrffri.obj
|
rdftodat.obj rdftoi.obj rgb.obj scan.obj simx.obj wrffrdat.obj wrffri.obj
|
||||||
|
|
||||||
!include $(WXWIN)\src\makelib.b32
|
!include $(WXWIN)\src\makelib.b32
|
||||||
|
@@ -17,17 +17,25 @@ LIBTARGET=$(WXDIR)\lib\xpm.lib
|
|||||||
|
|
||||||
XPMDIR=$(WXDIR)\src\xpm
|
XPMDIR=$(WXDIR)\src\xpm
|
||||||
|
|
||||||
OBJECTS = $(XPMDIR)\crbuffri.obj\
|
OBJECTS = $(XPMDIR)\attrib.obj\
|
||||||
|
$(XPMDIR)\crbuffri.obj\
|
||||||
$(XPMDIR)\crdatfri.obj\
|
$(XPMDIR)\crdatfri.obj\
|
||||||
$(XPMDIR)\create.obj $(XPMDIR)\crifrbuf.obj\
|
$(XPMDIR)\create.obj\
|
||||||
|
$(XPMDIR)\crifrbuf.obj\
|
||||||
$(XPMDIR)\crifrdat.obj\
|
$(XPMDIR)\crifrdat.obj\
|
||||||
$(XPMDIR)\data.obj\
|
$(XPMDIR)\data.obj\
|
||||||
$(XPMDIR)\hashtab.obj $(XPMDIR)\misc.obj\
|
$(XPMDIR)\image.obj\
|
||||||
$(XPMDIR)\parse.obj $(XPMDIR)\rdftodat.obj\
|
$(XPMDIR)\info.obj\
|
||||||
|
$(XPMDIR)\hashtab.obj\
|
||||||
|
$(XPMDIR)\misc.obj\
|
||||||
|
$(XPMDIR)\parse.obj\
|
||||||
|
$(XPMDIR)\rdftodat.obj\
|
||||||
$(XPMDIR)\rdftoi.obj\
|
$(XPMDIR)\rdftoi.obj\
|
||||||
$(XPMDIR)\rgb.obj $(XPMDIR)\scan.obj\
|
$(XPMDIR)\rgb.obj\
|
||||||
$(XPMDIR)\simx.obj $(XPMDIR)\wrffrdat.obj\
|
$(XPMDIR)\scan.obj\
|
||||||
$(XPMDIR)\wrffrp.obj $(XPMDIR)\wrffri.obj
|
$(XPMDIR)\simx.obj\
|
||||||
|
$(XPMDIR)\wrffrdat.obj\
|
||||||
|
$(XPMDIR)\wrffri.obj
|
||||||
|
|
||||||
all: $(LIBTARGET)
|
all: $(LIBTARGET)
|
||||||
|
|
||||||
@@ -39,26 +47,21 @@ $(LIBTARGET): $(OBJECTS)
|
|||||||
$(OBJECTS) $(PERIPH_LIBS)
|
$(OBJECTS) $(PERIPH_LIBS)
|
||||||
<<
|
<<
|
||||||
|
|
||||||
|
$(XPMDIR)\crbuffri.obj: $(XPMDIR)\attrib.c
|
||||||
|
cl @<<
|
||||||
|
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||||
|
<<
|
||||||
|
|
||||||
$(XPMDIR)\crbuffri.obj: $(XPMDIR)\crbuffri.c
|
$(XPMDIR)\crbuffri.obj: $(XPMDIR)\crbuffri.c
|
||||||
cl @<<
|
cl @<<
|
||||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||||
<<
|
<<
|
||||||
|
|
||||||
$(XPMDIR)\crbuffrp.obj: $(XPMDIR)\crbuffrp.c
|
|
||||||
cl @<<
|
|
||||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
|
||||||
<<
|
|
||||||
|
|
||||||
$(XPMDIR)\crdatfri.obj: $(XPMDIR)\crdatfri.c
|
$(XPMDIR)\crdatfri.obj: $(XPMDIR)\crdatfri.c
|
||||||
cl @<<
|
cl @<<
|
||||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||||
<<
|
<<
|
||||||
|
|
||||||
$(XPMDIR)\crdatfrp.obj: $(XPMDIR)\crdatfrp.c
|
|
||||||
cl @<<
|
|
||||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
|
||||||
<<
|
|
||||||
|
|
||||||
$(XPMDIR)\create.obj: $(XPMDIR)\create.c
|
$(XPMDIR)\create.obj: $(XPMDIR)\create.c
|
||||||
cl @<<
|
cl @<<
|
||||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||||
@@ -74,21 +77,21 @@ $(XPMDIR)\crifrdat.obj: $(XPMDIR)\crifrdat.c
|
|||||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||||
<<
|
<<
|
||||||
|
|
||||||
$(XPMDIR)\crpfrbuf.obj: $(XPMDIR)\crpfrbuf.c
|
|
||||||
cl @<<
|
|
||||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
|
||||||
<<
|
|
||||||
|
|
||||||
$(XPMDIR)\crpfrdat.obj: $(XPMDIR)\crpfrdat.c
|
|
||||||
cl @<<
|
|
||||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
|
||||||
<<
|
|
||||||
|
|
||||||
$(XPMDIR)\data.obj: $(XPMDIR)\data.c
|
$(XPMDIR)\data.obj: $(XPMDIR)\data.c
|
||||||
cl @<<
|
cl @<<
|
||||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||||
<<
|
<<
|
||||||
|
|
||||||
|
$(XPMDIR)\data.obj: $(XPMDIR)\image.c
|
||||||
|
cl @<<
|
||||||
|
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||||
|
<<
|
||||||
|
|
||||||
|
$(XPMDIR)\data.obj: $(XPMDIR)\info.c
|
||||||
|
cl @<<
|
||||||
|
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||||
|
<<
|
||||||
|
|
||||||
$(XPMDIR)\hashtab.obj: $(XPMDIR)\hashtab.c
|
$(XPMDIR)\hashtab.obj: $(XPMDIR)\hashtab.c
|
||||||
cl @<<
|
cl @<<
|
||||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||||
@@ -114,11 +117,6 @@ $(XPMDIR)\rdftoi.obj: $(XPMDIR)\rdftoi.c
|
|||||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||||
<<
|
<<
|
||||||
|
|
||||||
$(XPMDIR)\rdftop.obj: $(XPMDIR)\rdftop.c
|
|
||||||
cl @<<
|
|
||||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
|
||||||
<<
|
|
||||||
|
|
||||||
$(XPMDIR)\rgb.obj: $(XPMDIR)\rgb.c
|
$(XPMDIR)\rgb.obj: $(XPMDIR)\rgb.c
|
||||||
cl @<<
|
cl @<<
|
||||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||||
@@ -144,11 +142,6 @@ $(XPMDIR)\wrffri.obj: $(XPMDIR)\wrffri.c
|
|||||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
$(CPPFLAGS2) /c $*.c /Fo$@
|
||||||
<<
|
<<
|
||||||
|
|
||||||
$(XPMDIR)\wrffrp.obj: $(XPMDIR)\wrffrp.c
|
|
||||||
cl @<<
|
|
||||||
$(CPPFLAGS2) /c $*.c /Fo$@
|
|
||||||
<<
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-erase *.obj
|
-erase *.obj
|
||||||
-erase $(LIBTARGET)
|
-erase $(LIBTARGET)
|
||||||
|
@@ -14,23 +14,25 @@ WXLIB = $(WXDIR)\lib
|
|||||||
|
|
||||||
LIBTARGET = $(WXLIB)\xpm.lib
|
LIBTARGET = $(WXLIB)\xpm.lib
|
||||||
|
|
||||||
OBJECTS = crbuffri.obj &
|
OBJECTS = attrib.obj &
|
||||||
|
crbuffri.obj &
|
||||||
crdatfri.obj &
|
crdatfri.obj &
|
||||||
create.obj &
|
create.obj &
|
||||||
crifrbuf.obj &
|
crifrbuf.obj &
|
||||||
crifrdat.obj &
|
crifrdat.obj &
|
||||||
data.obj &
|
data.obj &
|
||||||
|
image.obj &
|
||||||
|
info.obj &
|
||||||
hashtab.obj &
|
hashtab.obj &
|
||||||
misc.obj &
|
misc.obj &
|
||||||
parse.obj &
|
parse.obj &
|
||||||
rdftodat.obj &
|
rdftodat.obj &
|
||||||
rdftoi.obj &
|
rdftoi.obj &
|
||||||
rgb.obj &
|
rgb.obj &
|
||||||
scan.obj &
|
scan.obj &
|
||||||
simx.obj &
|
simx.obj &
|
||||||
wrffrdat.obj &
|
wrffrdat.obj &
|
||||||
wrffrp.obj &
|
wrffri.obj
|
||||||
wrffri.obj
|
|
||||||
|
|
||||||
all: $(OBJECTS) $(LIBTARGET)
|
all: $(OBJECTS) $(LIBTARGET)
|
||||||
|
|
||||||
|
486
src/xpm/misc.c
486
src/xpm/misc.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -32,376 +32,7 @@
|
|||||||
* Developed by Arnaud Le Hors *
|
* Developed by Arnaud Le Hors *
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
/*
|
#include "XpmI.h"
|
||||||
* The code related to FOR_MSW has been added by
|
|
||||||
* HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "xpm34p.h"
|
|
||||||
#ifdef VMS
|
|
||||||
#include "sys$library:stat.h"
|
|
||||||
#include "sys$library:fcntl.h"
|
|
||||||
#else
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#ifdef FOR_MSW
|
|
||||||
#include <io.h>
|
|
||||||
#else
|
|
||||||
#include <unistd.h>
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* 3.2 backward compatibility code */
|
|
||||||
LFUNC(CreateOldColorTable, int, (XpmColor *ct, int ncolors,
|
|
||||||
XpmColor ***oldct));
|
|
||||||
|
|
||||||
LFUNC(FreeOldColorTable, void, (XpmColor **colorTable, int ncolors));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Create a colortable compatible with the old style colortable
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
CreateOldColorTable(XpmColor *ct, int ncolors, XpmColor ***oldct)
|
|
||||||
{
|
|
||||||
XpmColor **colorTable, **color;
|
|
||||||
int a;
|
|
||||||
|
|
||||||
colorTable = (XpmColor **) XpmMalloc(ncolors * sizeof(XpmColor *));
|
|
||||||
if (!colorTable) {
|
|
||||||
*oldct = NULL;
|
|
||||||
return (XpmNoMemory);
|
|
||||||
}
|
|
||||||
for (a = 0, color = colorTable; a < ncolors; a++, color++, ct++)
|
|
||||||
*color = ct;
|
|
||||||
*oldct = colorTable;
|
|
||||||
return (XpmSuccess);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
FreeOldColorTable(XpmColor **colorTable, int ncolors)
|
|
||||||
{
|
|
||||||
int a, b;
|
|
||||||
XpmColor **color;
|
|
||||||
char **sptr;
|
|
||||||
|
|
||||||
if (colorTable) {
|
|
||||||
for (a = 0, color = colorTable; a < ncolors; a++, color++) {
|
|
||||||
for (b = 0, sptr = (char **) *color; b <= NKEYS; b++, sptr++)
|
|
||||||
if (*sptr)
|
|
||||||
XpmFree(*sptr);
|
|
||||||
}
|
|
||||||
XpmFree(*colorTable);
|
|
||||||
XpmFree(colorTable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* end 3.2 bc */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Free the computed color table
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xpmFreeColorTable(XpmColor *colorTable, int ncolors)
|
|
||||||
{
|
|
||||||
int a, b;
|
|
||||||
XpmColor *color;
|
|
||||||
char **sptr;
|
|
||||||
|
|
||||||
if (colorTable) {
|
|
||||||
for (a = 0, color = colorTable; a < ncolors; a++, color++) {
|
|
||||||
for (b = 0, sptr = (char **) color; b <= NKEYS; b++, sptr++)
|
|
||||||
if (*sptr)
|
|
||||||
XpmFree(*sptr);
|
|
||||||
}
|
|
||||||
XpmFree(colorTable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Free array of extensions
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
XpmFreeExtensions(XpmExtension *extensions, int nextensions)
|
|
||||||
{
|
|
||||||
unsigned int i, j, nlines;
|
|
||||||
XpmExtension *ext;
|
|
||||||
char **sptr;
|
|
||||||
|
|
||||||
if (extensions) {
|
|
||||||
for (i = 0, ext = extensions; i < (unsigned int)nextensions; i++, ext++) {
|
|
||||||
if (ext->name)
|
|
||||||
XpmFree(ext->name);
|
|
||||||
nlines = ext->nlines;
|
|
||||||
for (j = 0, sptr = ext->lines; j < nlines; j++, sptr++)
|
|
||||||
if (*sptr)
|
|
||||||
XpmFree(*sptr);
|
|
||||||
if (ext->lines)
|
|
||||||
XpmFree(ext->lines);
|
|
||||||
}
|
|
||||||
XpmFree(extensions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return the XpmAttributes structure size
|
|
||||||
*/
|
|
||||||
|
|
||||||
int
|
|
||||||
XpmAttributesSize()
|
|
||||||
{
|
|
||||||
return sizeof(XpmAttributes);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Init returned data to free safely later on
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xpmInitAttributes(XpmAttributes *attributes)
|
|
||||||
{
|
|
||||||
if (attributes) {
|
|
||||||
attributes->pixels = NULL;
|
|
||||||
attributes->npixels = 0;
|
|
||||||
attributes->colorTable = NULL;
|
|
||||||
attributes->ncolors = 0;
|
|
||||||
/* 3.2 backward compatibility code */
|
|
||||||
attributes->hints_cmt = NULL;
|
|
||||||
attributes->colors_cmt = NULL;
|
|
||||||
attributes->pixels_cmt = NULL;
|
|
||||||
/* end 3.2 bc */
|
|
||||||
attributes->extensions = NULL;
|
|
||||||
attributes->nextensions = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fill in the XpmAttributes with the XpmImage and the XpmInfo
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xpmSetAttributes(XpmAttributes *attributes, XpmImage *image, XpmInfo *info)
|
|
||||||
{
|
|
||||||
if (attributes->valuemask & XpmReturnColorTable) {
|
|
||||||
attributes->colorTable = image->colorTable;
|
|
||||||
attributes->ncolors = image->ncolors;
|
|
||||||
|
|
||||||
/* avoid deletion of copied data */
|
|
||||||
image->ncolors = 0;
|
|
||||||
image->colorTable = NULL;
|
|
||||||
}
|
|
||||||
/* 3.2 backward compatibility code */
|
|
||||||
else if (attributes->valuemask & XpmReturnInfos) {
|
|
||||||
int ErrorStatus;
|
|
||||||
|
|
||||||
ErrorStatus = CreateOldColorTable(image->colorTable, image->ncolors,
|
|
||||||
(XpmColor ***)
|
|
||||||
&attributes->colorTable);
|
|
||||||
|
|
||||||
/* if error just say we can't return requested data */
|
|
||||||
if (ErrorStatus != XpmSuccess) {
|
|
||||||
attributes->valuemask &= ~XpmReturnInfos;
|
|
||||||
if (!(attributes->valuemask & XpmReturnPixels)) {
|
|
||||||
XpmFree(attributes->pixels);
|
|
||||||
attributes->pixels = NULL;
|
|
||||||
attributes->npixels = 0;
|
|
||||||
}
|
|
||||||
attributes->ncolors = 0;
|
|
||||||
} else {
|
|
||||||
attributes->ncolors = image->ncolors;
|
|
||||||
attributes->hints_cmt = info->hints_cmt;
|
|
||||||
attributes->colors_cmt = info->colors_cmt;
|
|
||||||
attributes->pixels_cmt = info->pixels_cmt;
|
|
||||||
|
|
||||||
/* avoid deletion of copied data */
|
|
||||||
image->ncolors = 0;
|
|
||||||
image->colorTable = NULL;
|
|
||||||
info->hints_cmt = NULL;
|
|
||||||
info->colors_cmt = NULL;
|
|
||||||
info->pixels_cmt = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* end 3.2 bc */
|
|
||||||
if (attributes->valuemask & XpmReturnExtensions) {
|
|
||||||
attributes->extensions = info->extensions;
|
|
||||||
attributes->nextensions = info->nextensions;
|
|
||||||
|
|
||||||
/* avoid deletion of copied data */
|
|
||||||
info->extensions = NULL;
|
|
||||||
info->nextensions = 0;
|
|
||||||
}
|
|
||||||
if (info->valuemask & XpmHotspot) {
|
|
||||||
attributes->valuemask |= XpmHotspot;
|
|
||||||
attributes->x_hotspot = info->x_hotspot;
|
|
||||||
attributes->y_hotspot = info->y_hotspot;
|
|
||||||
}
|
|
||||||
attributes->valuemask |= XpmCharsPerPixel;
|
|
||||||
attributes->cpp = image->cpp;
|
|
||||||
attributes->valuemask |= XpmSize;
|
|
||||||
attributes->width = image->width;
|
|
||||||
attributes->height = image->height;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Free the XpmAttributes structure members
|
|
||||||
* but the structure itself
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
XpmFreeAttributes(XpmAttributes *attributes)
|
|
||||||
{
|
|
||||||
if (attributes->valuemask & XpmReturnPixels && attributes->npixels) {
|
|
||||||
XpmFree(attributes->pixels);
|
|
||||||
attributes->pixels = NULL;
|
|
||||||
attributes->npixels = 0;
|
|
||||||
}
|
|
||||||
if (attributes->valuemask & XpmReturnColorTable) {
|
|
||||||
xpmFreeColorTable(attributes->colorTable, attributes->ncolors);
|
|
||||||
attributes->colorTable = NULL;
|
|
||||||
attributes->ncolors = 0;
|
|
||||||
}
|
|
||||||
/* 3.2 backward compatibility code */
|
|
||||||
else if (attributes->valuemask & XpmInfos) {
|
|
||||||
if (attributes->colorTable) {
|
|
||||||
FreeOldColorTable((XpmColor **) attributes->colorTable,
|
|
||||||
attributes->ncolors);
|
|
||||||
attributes->colorTable = NULL;
|
|
||||||
attributes->ncolors = 0;
|
|
||||||
}
|
|
||||||
if (attributes->hints_cmt) {
|
|
||||||
XpmFree(attributes->hints_cmt);
|
|
||||||
attributes->hints_cmt = NULL;
|
|
||||||
}
|
|
||||||
if (attributes->colors_cmt) {
|
|
||||||
XpmFree(attributes->colors_cmt);
|
|
||||||
attributes->colors_cmt = NULL;
|
|
||||||
}
|
|
||||||
if (attributes->pixels_cmt) {
|
|
||||||
XpmFree(attributes->pixels_cmt);
|
|
||||||
attributes->pixels_cmt = NULL;
|
|
||||||
}
|
|
||||||
if (attributes->pixels) {
|
|
||||||
XpmFree(attributes->pixels);
|
|
||||||
attributes->pixels = NULL;
|
|
||||||
attributes->npixels = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* end 3.2 bc */
|
|
||||||
if (attributes->valuemask & XpmReturnExtensions
|
|
||||||
&& attributes->nextensions) {
|
|
||||||
XpmFreeExtensions(attributes->extensions, attributes->nextensions);
|
|
||||||
attributes->extensions = NULL;
|
|
||||||
attributes->nextensions = 0;
|
|
||||||
}
|
|
||||||
attributes->valuemask = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Init returned data to free safely later on
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xpmInitXpmImage(XpmImage *image)
|
|
||||||
{
|
|
||||||
image->ncolors = 0;
|
|
||||||
image->colorTable = NULL;
|
|
||||||
image->data = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Free the XpmImage data which have been allocated
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
XpmFreeXpmImage(XpmImage *image)
|
|
||||||
{
|
|
||||||
if (image->colorTable)
|
|
||||||
xpmFreeColorTable(image->colorTable, image->ncolors);
|
|
||||||
XpmFree(image->data);
|
|
||||||
image->data = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Init returned data to free safely later on
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xpmInitXpmInfo(XpmInfo *info)
|
|
||||||
{
|
|
||||||
if (info) {
|
|
||||||
info->hints_cmt = NULL;
|
|
||||||
info->colors_cmt = NULL;
|
|
||||||
info->pixels_cmt = NULL;
|
|
||||||
info->extensions = NULL;
|
|
||||||
info->nextensions = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Free the XpmInfo data which have been allocated
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
XpmFreeXpmInfo(XpmInfo *info)
|
|
||||||
{
|
|
||||||
if (info) {
|
|
||||||
if (info->valuemask & XpmComments) {
|
|
||||||
if (info->hints_cmt) {
|
|
||||||
XpmFree(info->hints_cmt);
|
|
||||||
info->hints_cmt = NULL;
|
|
||||||
}
|
|
||||||
if (info->colors_cmt) {
|
|
||||||
XpmFree(info->colors_cmt);
|
|
||||||
info->colors_cmt = NULL;
|
|
||||||
}
|
|
||||||
if (info->pixels_cmt) {
|
|
||||||
XpmFree(info->pixels_cmt);
|
|
||||||
info->pixels_cmt = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (info->valuemask & XpmReturnExtensions && info->nextensions) {
|
|
||||||
XpmFreeExtensions(info->extensions, info->nextensions);
|
|
||||||
info->extensions = NULL;
|
|
||||||
info->nextensions = 0;
|
|
||||||
}
|
|
||||||
info->valuemask = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set the XpmInfo valuemask to retrieve required info
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xpmSetInfoMask(XpmInfo *info, XpmAttributes *attributes)
|
|
||||||
{
|
|
||||||
info->valuemask = 0;
|
|
||||||
if (attributes->valuemask & XpmReturnInfos)
|
|
||||||
info->valuemask |= XpmReturnComments;
|
|
||||||
if (attributes->valuemask & XpmReturnExtensions)
|
|
||||||
info->valuemask |= XpmReturnExtensions;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fill in the XpmInfo with the XpmAttributes
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xpmSetInfo(XpmInfo *info, XpmAttributes *attributes)
|
|
||||||
{
|
|
||||||
info->valuemask = 0;
|
|
||||||
if (attributes->valuemask & XpmInfos) {
|
|
||||||
info->valuemask |= XpmComments | XpmColorTable;
|
|
||||||
info->hints_cmt = attributes->hints_cmt;
|
|
||||||
info->colors_cmt = attributes->colors_cmt;
|
|
||||||
info->pixels_cmt = attributes->pixels_cmt;
|
|
||||||
}
|
|
||||||
if (attributes->valuemask & XpmExtensions) {
|
|
||||||
info->valuemask |= XpmExtensions;
|
|
||||||
info->extensions = attributes->extensions;
|
|
||||||
info->nextensions = attributes->nextensions;
|
|
||||||
}
|
|
||||||
if (attributes->valuemask & XpmHotspot) {
|
|
||||||
info->valuemask |= XpmHotspot;
|
|
||||||
info->x_hotspot = attributes->x_hotspot;
|
|
||||||
info->y_hotspot = attributes->y_hotspot;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef NEED_STRDUP
|
#ifdef NEED_STRDUP
|
||||||
/*
|
/*
|
||||||
@@ -409,20 +40,24 @@ xpmSetInfo(XpmInfo *info, XpmAttributes *attributes)
|
|||||||
* which does the trick
|
* which does the trick
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
strdup(char *s1)
|
xpmstrdup(s1)
|
||||||
|
char *s1;
|
||||||
{
|
{
|
||||||
char *s2;
|
char *s2;
|
||||||
int l = strlen(s1) + 1;
|
int l = strlen(s1) + 1;
|
||||||
|
|
||||||
if (s2 = (char *) XpmMalloc(l))
|
if (s2 = (char *) XpmMalloc(l))
|
||||||
strncpy(s2, s1, l);
|
strcpy(s2, s1);
|
||||||
return s2;
|
return s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned int
|
unsigned int
|
||||||
atoui(register char *p, unsigned int l, unsigned int *ui_return)
|
xpmatoui(p, l, ui_return)
|
||||||
|
register char *p;
|
||||||
|
unsigned int l;
|
||||||
|
unsigned int *ui_return;
|
||||||
{
|
{
|
||||||
register unsigned int n, i;
|
register unsigned int n, i;
|
||||||
|
|
||||||
@@ -440,74 +75,12 @@ atoui(register char *p, unsigned int l, unsigned int *ui_return)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* File / Buffer utilities
|
* Function returning a character string related to an error code.
|
||||||
*/
|
|
||||||
int
|
|
||||||
XpmReadFileToBuffer(char *filename, char **buffer_return)
|
|
||||||
{
|
|
||||||
int fd, fcheck, len;
|
|
||||||
char *ptr;
|
|
||||||
struct stat stats;
|
|
||||||
FILE *fp;
|
|
||||||
|
|
||||||
*buffer_return = NULL;
|
|
||||||
|
|
||||||
fd = open(filename, O_RDONLY);
|
|
||||||
if (fd < 0)
|
|
||||||
return XpmOpenFailed;
|
|
||||||
|
|
||||||
if (fstat(fd, &stats)) {
|
|
||||||
close(fd);
|
|
||||||
return XpmOpenFailed;
|
|
||||||
}
|
|
||||||
fp = fdopen(fd, "r");
|
|
||||||
if (!fp) {
|
|
||||||
close(fd);
|
|
||||||
return XpmOpenFailed;
|
|
||||||
}
|
|
||||||
len = (int) stats.st_size;
|
|
||||||
ptr = (char *) XpmMalloc(len + 1);
|
|
||||||
if (!ptr) {
|
|
||||||
fclose(fp);
|
|
||||||
return XpmNoMemory;
|
|
||||||
}
|
|
||||||
fcheck = fread(ptr, len, 1, fp);
|
|
||||||
fclose(fp);
|
|
||||||
if (fcheck != 1) {
|
|
||||||
XpmFree(ptr);
|
|
||||||
return XpmOpenFailed;
|
|
||||||
}
|
|
||||||
ptr[len] = '\0';
|
|
||||||
*buffer_return = ptr;
|
|
||||||
return XpmSuccess;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
XpmWriteFileFromBuffer(char *filename, char *buffer)
|
|
||||||
{
|
|
||||||
int fcheck, len;
|
|
||||||
FILE *fp = fopen(filename, "w");
|
|
||||||
|
|
||||||
if (!fp)
|
|
||||||
return XpmOpenFailed;
|
|
||||||
|
|
||||||
len = strlen(buffer);
|
|
||||||
fcheck = fwrite(buffer, len, 1, fp);
|
|
||||||
fclose(fp);
|
|
||||||
if (fcheck != 1)
|
|
||||||
return XpmOpenFailed;
|
|
||||||
|
|
||||||
return XpmSuccess;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Small utility function
|
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
XpmGetErrorString(int errcode)
|
XpmGetErrorString(errcode)
|
||||||
|
int errcode;
|
||||||
{
|
{
|
||||||
switch (errcode) {
|
switch (errcode) {
|
||||||
case XpmColorError:
|
case XpmColorError:
|
||||||
@@ -538,35 +111,14 @@ XpmLibraryVersion()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef FOR_MSW
|
/* The following should help people wanting to use their own functions */
|
||||||
void
|
#ifdef XpmFree
|
||||||
xpmCreatePixmapFromImage(Display *display, Drawable d, XImage *ximage, Pixmap *pixmap_return)
|
#undef XpmFree
|
||||||
{
|
#endif
|
||||||
GC gc;
|
|
||||||
|
|
||||||
*pixmap_return = XCreatePixmap(display, d, ximage->width,
|
|
||||||
ximage->height, ximage->depth);
|
|
||||||
gc = XCreateGC(display, *pixmap_return, 0, NULL);
|
|
||||||
|
|
||||||
XPutImage(display, *pixmap_return, gc, ximage, 0, 0, 0, 0,
|
|
||||||
ximage->width, ximage->height);
|
|
||||||
|
|
||||||
XFreeGC(display, gc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
xpmCreateImageFromPixmap(Display *display, Pixmap pixmap, XImage **ximage_return, unsigned int *width, unsigned int *height)
|
XpmFree(ptr)
|
||||||
|
void *ptr;
|
||||||
{
|
{
|
||||||
unsigned int dum;
|
free(ptr);
|
||||||
int dummy;
|
|
||||||
Window win;
|
|
||||||
|
|
||||||
if (*width == 0 && *height == 0)
|
|
||||||
XGetGeometry(display, pixmap, &win, &dummy, &dummy,
|
|
||||||
width, height, &dum, &dum);
|
|
||||||
|
|
||||||
*ximage_return = XGetImage(display, pixmap, 0, 0, *width, *height,
|
|
||||||
AllPlanes, ZPixmap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* FOR_MSW */
|
|
||||||
|
458
src/xpm/parse.c
458
src/xpm/parse.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -38,42 +38,14 @@
|
|||||||
* HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
|
* HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "xpm34p.h"
|
#include "XpmI.h"
|
||||||
#ifdef VMS
|
|
||||||
#include "sys$library:ctype.h"
|
|
||||||
#else
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef sun
|
|
||||||
#ifdef SVR4
|
|
||||||
#define __ORIGINAL_XORG_CODE
|
|
||||||
#include <X11/Xfuncs.h> /* bzero, bcopy */
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#ifdef __sgi
|
|
||||||
#include <bstring.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LFUNC(ParseValues, int, (xpmData *data, unsigned int *width,
|
|
||||||
unsigned int *height, unsigned int *ncolors,
|
|
||||||
unsigned int *cpp, unsigned int *x_hotspot,
|
|
||||||
unsigned int *y_hotspot, unsigned int *hotspot,
|
|
||||||
unsigned int *extensions));
|
|
||||||
|
|
||||||
LFUNC(ParseColors, int, (xpmData *data, unsigned int ncolors, unsigned int cpp,
|
|
||||||
XpmColor **colorTablePtr, xpmHashTable *hashtable));
|
|
||||||
|
|
||||||
LFUNC(ParsePixels, int, (xpmData *data, unsigned int width,
|
LFUNC(ParsePixels, int, (xpmData *data, unsigned int width,
|
||||||
unsigned int height, unsigned int ncolors,
|
unsigned int height, unsigned int ncolors,
|
||||||
unsigned int cpp, XpmColor *colorTable,
|
unsigned int cpp, XpmColor *colorTable,
|
||||||
xpmHashTable *hashtable, unsigned int **pixels));
|
xpmHashTable *hashtable, unsigned int **pixels));
|
||||||
|
|
||||||
LFUNC(ParseExtensions, int, (xpmData *data, XpmExtension **extensions,
|
|
||||||
unsigned int *nextensions));
|
|
||||||
|
|
||||||
char *xpmColorKeys[] = {
|
char *xpmColorKeys[] = {
|
||||||
"s", /* key #1: symbol */
|
"s", /* key #1: symbol */
|
||||||
"m", /* key #2: mono visual */
|
"m", /* key #2: mono visual */
|
||||||
@@ -82,147 +54,13 @@ char *xpmColorKeys[] = {
|
|||||||
"c", /* key #5: color visual */
|
"c", /* key #5: color visual */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* function call in case of error, frees only locally allocated variables */
|
|
||||||
#undef RETURN
|
|
||||||
#define RETURN(status) \
|
|
||||||
{ \
|
|
||||||
if (colorTable) xpmFreeColorTable(colorTable, ncolors); \
|
|
||||||
if (pixelindex) XpmFree(pixelindex); \
|
|
||||||
if (hints_cmt) XpmFree(hints_cmt); \
|
|
||||||
if (colors_cmt) XpmFree(colors_cmt); \
|
|
||||||
if (pixels_cmt) XpmFree(pixels_cmt); \
|
|
||||||
return(status); \
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This function parses an Xpm file or data and store the found informations
|
|
||||||
* in an an XpmImage structure which is returned.
|
|
||||||
*/
|
|
||||||
int
|
int
|
||||||
xpmParseData(xpmData *data, XpmImage *image, XpmInfo *info)
|
xpmParseValues(data, width, height, ncolors, cpp,
|
||||||
{
|
x_hotspot, y_hotspot, hotspot, extensions)
|
||||||
/* variables to return */
|
xpmData *data;
|
||||||
unsigned int width, height, ncolors, cpp;
|
unsigned int *width, *height, *ncolors, *cpp;
|
||||||
unsigned int x_hotspot, y_hotspot, hotspot = 0, extensions = 0;
|
unsigned int *x_hotspot, *y_hotspot, *hotspot;
|
||||||
XpmColor *colorTable = NULL;
|
unsigned int *extensions;
|
||||||
unsigned int *pixelindex = NULL;
|
|
||||||
char *hints_cmt = NULL;
|
|
||||||
char *colors_cmt = NULL;
|
|
||||||
char *pixels_cmt = NULL;
|
|
||||||
|
|
||||||
unsigned int cmts;
|
|
||||||
int ErrorStatus;
|
|
||||||
xpmHashTable hashtable;
|
|
||||||
|
|
||||||
cmts = info && (info->valuemask & XpmReturnComments);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* parse the header
|
|
||||||
*/
|
|
||||||
ErrorStatus = xpmParseHeader(data);
|
|
||||||
if (ErrorStatus != XpmSuccess)
|
|
||||||
return (ErrorStatus);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* read values
|
|
||||||
*/
|
|
||||||
ErrorStatus = ParseValues(data, &width, &height, &ncolors, &cpp,
|
|
||||||
&x_hotspot, &y_hotspot, &hotspot, &extensions);
|
|
||||||
if (ErrorStatus != XpmSuccess)
|
|
||||||
return (ErrorStatus);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* store the hints comment line
|
|
||||||
*/
|
|
||||||
if (cmts)
|
|
||||||
xpmGetCmt(data, &hints_cmt);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* init the hastable
|
|
||||||
*/
|
|
||||||
if (USE_HASHTABLE) {
|
|
||||||
ErrorStatus = xpmHashTableInit(&hashtable);
|
|
||||||
if (ErrorStatus != XpmSuccess)
|
|
||||||
return (ErrorStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* read colors
|
|
||||||
*/
|
|
||||||
ErrorStatus = ParseColors(data, ncolors, cpp, &colorTable, &hashtable);
|
|
||||||
if (ErrorStatus != XpmSuccess)
|
|
||||||
RETURN(ErrorStatus);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* store the colors comment line
|
|
||||||
*/
|
|
||||||
if (cmts)
|
|
||||||
xpmGetCmt(data, &colors_cmt);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* read pixels and index them on color number
|
|
||||||
*/
|
|
||||||
ErrorStatus = ParsePixels(data, width, height, ncolors, cpp, colorTable,
|
|
||||||
&hashtable, &pixelindex);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* free the hastable
|
|
||||||
*/
|
|
||||||
if (USE_HASHTABLE)
|
|
||||||
xpmHashTableFree(&hashtable);
|
|
||||||
|
|
||||||
if (ErrorStatus != XpmSuccess)
|
|
||||||
RETURN(ErrorStatus);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* store the pixels comment line
|
|
||||||
*/
|
|
||||||
if (cmts)
|
|
||||||
xpmGetCmt(data, &pixels_cmt);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* parse extensions
|
|
||||||
*/
|
|
||||||
if (info && (info->valuemask & XpmReturnExtensions))
|
|
||||||
if (extensions) {
|
|
||||||
ErrorStatus = ParseExtensions(data, &info->extensions,
|
|
||||||
&info->nextensions);
|
|
||||||
if (ErrorStatus != XpmSuccess)
|
|
||||||
RETURN(ErrorStatus);
|
|
||||||
} else {
|
|
||||||
info->extensions = NULL;
|
|
||||||
info->nextensions = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* store found informations in the XpmImage structure
|
|
||||||
*/
|
|
||||||
image->width = width;
|
|
||||||
image->height = height;
|
|
||||||
image->cpp = cpp;
|
|
||||||
image->ncolors = ncolors;
|
|
||||||
image->colorTable = colorTable;
|
|
||||||
image->data = pixelindex;
|
|
||||||
|
|
||||||
if (info) {
|
|
||||||
if (cmts) {
|
|
||||||
info->hints_cmt = hints_cmt;
|
|
||||||
info->colors_cmt = colors_cmt;
|
|
||||||
info->pixels_cmt = pixels_cmt;
|
|
||||||
}
|
|
||||||
if (hotspot) {
|
|
||||||
info->x_hotspot = x_hotspot;
|
|
||||||
info->y_hotspot = y_hotspot;
|
|
||||||
info->valuemask |= XpmHotspot;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (XpmSuccess);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
ParseValues(xpmData *data, unsigned int *width, unsigned int *height, unsigned int *ncolors, unsigned int *cpp,
|
|
||||||
unsigned int *x_hotspot, unsigned int *y_hotspot, unsigned int *hotspot, unsigned int *extensions)
|
|
||||||
{
|
{
|
||||||
unsigned int l;
|
unsigned int l;
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
@@ -246,7 +84,7 @@ ParseValues(xpmData *data, unsigned int *width, unsigned int *height, unsigned i
|
|||||||
*hotspot = (xpmNextUI(data, x_hotspot)
|
*hotspot = (xpmNextUI(data, x_hotspot)
|
||||||
&& xpmNextUI(data, y_hotspot));
|
&& xpmNextUI(data, y_hotspot));
|
||||||
else {
|
else {
|
||||||
*hotspot = (atoui(buf, l, x_hotspot)
|
*hotspot = (xpmatoui(buf, l, x_hotspot)
|
||||||
&& xpmNextUI(data, y_hotspot));
|
&& xpmNextUI(data, y_hotspot));
|
||||||
l = xpmNextWord(data, buf, BUFSIZ);
|
l = xpmNextWord(data, buf, BUFSIZ);
|
||||||
*extensions = (l == 6 && !strncmp("XPMEXT", buf, 6));
|
*extensions = (l == 6 && !strncmp("XPMEXT", buf, 6));
|
||||||
@@ -259,6 +97,8 @@ ParseValues(xpmData *data, unsigned int *width, unsigned int *height, unsigned i
|
|||||||
*/
|
*/
|
||||||
int i;
|
int i;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
Bool got_one, saw_width = False, saw_height = False;
|
||||||
|
Bool saw_ncolors = False, saw_chars_per_pixel = False;
|
||||||
|
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
l = xpmNextWord(data, buf, BUFSIZ);
|
l = xpmNextWord(data, buf, BUFSIZ);
|
||||||
@@ -267,41 +107,70 @@ ParseValues(xpmData *data, unsigned int *width, unsigned int *height, unsigned i
|
|||||||
l = xpmNextWord(data, buf, BUFSIZ);
|
l = xpmNextWord(data, buf, BUFSIZ);
|
||||||
if (!l)
|
if (!l)
|
||||||
return (XpmFileInvalid);
|
return (XpmFileInvalid);
|
||||||
ptr = strchr(buf, '_');
|
buf[l] = '\0';
|
||||||
if (!ptr)
|
ptr = buf;
|
||||||
return (XpmFileInvalid);
|
got_one = False;
|
||||||
switch (l - (ptr - buf)) {
|
while (!got_one) {
|
||||||
case 6:
|
ptr = index(ptr, '_');
|
||||||
if (!strncmp("_width", ptr, 6) && !xpmNextUI(data, width))
|
if (!ptr)
|
||||||
return (XpmFileInvalid);
|
return (XpmFileInvalid);
|
||||||
break;
|
switch (l - (ptr - buf)) {
|
||||||
case 7:
|
case 6:
|
||||||
if (!strncmp("_height", ptr, 7) && !xpmNextUI(data, height))
|
if (saw_width || strncmp("_width", ptr, 6)
|
||||||
return (XpmFileInvalid);
|
|| !xpmNextUI(data, width))
|
||||||
break;
|
return (XpmFileInvalid);
|
||||||
case 8:
|
else
|
||||||
if (!strncmp("_ncolors", ptr, 8) && !xpmNextUI(data, ncolors))
|
saw_width = True;
|
||||||
return (XpmFileInvalid);
|
got_one = True;
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 7:
|
||||||
if (!strncmp("_chars_per_pixel", ptr, 16)
|
if (saw_height || strncmp("_height", ptr, 7)
|
||||||
&& !xpmNextUI(data, cpp))
|
|| !xpmNextUI(data, height))
|
||||||
return (XpmFileInvalid);
|
return (XpmFileInvalid);
|
||||||
break;
|
else
|
||||||
default:
|
saw_height = True;
|
||||||
return (XpmFileInvalid);
|
got_one = True;
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
if (saw_ncolors || strncmp("_ncolors", ptr, 8)
|
||||||
|
|| !xpmNextUI(data, ncolors))
|
||||||
|
return (XpmFileInvalid);
|
||||||
|
else
|
||||||
|
saw_ncolors = True;
|
||||||
|
got_one = True;
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
if (saw_chars_per_pixel
|
||||||
|
|| strncmp("_chars_per_pixel", ptr, 16)
|
||||||
|
|| !xpmNextUI(data, cpp))
|
||||||
|
return (XpmFileInvalid);
|
||||||
|
else
|
||||||
|
saw_chars_per_pixel = True;
|
||||||
|
got_one = True;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* skip the end of line */
|
/* skip the end of line */
|
||||||
xpmNextString(data);
|
xpmNextString(data);
|
||||||
}
|
}
|
||||||
|
if (!saw_width || !saw_height || !saw_ncolors || !saw_chars_per_pixel)
|
||||||
|
return (XpmFileInvalid);
|
||||||
|
|
||||||
*hotspot = 0;
|
*hotspot = 0;
|
||||||
*extensions = 0;
|
*extensions = 0;
|
||||||
}
|
}
|
||||||
return (XpmSuccess);
|
return (XpmSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int
|
||||||
ParseColors(xpmData *data, unsigned int ncolors, unsigned int cpp, XpmColor **colorTablePtr, xpmHashTable *hashtable)
|
xpmParseColors(data, ncolors, cpp, colorTablePtr, hashtable)
|
||||||
|
xpmData *data;
|
||||||
|
unsigned int ncolors;
|
||||||
|
unsigned int cpp;
|
||||||
|
XpmColor **colorTablePtr;
|
||||||
|
xpmHashTable *hashtable;
|
||||||
{
|
{
|
||||||
unsigned int key, l, a, b;
|
unsigned int key, l, a, b;
|
||||||
unsigned int curkey; /* current color key */
|
unsigned int curkey; /* current color key */
|
||||||
@@ -456,8 +325,15 @@ ParseColors(xpmData *data, unsigned int ncolors, unsigned int cpp, XpmColor **co
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ParsePixels(xpmData *data, unsigned int width, unsigned int height, unsigned int ncolors,
|
ParsePixels(data, width, height, ncolors, cpp, colorTable, hashtable, pixels)
|
||||||
unsigned int cpp, XpmColor *colorTable, xpmHashTable *hashtable, unsigned int **pixels)
|
xpmData *data;
|
||||||
|
unsigned int width;
|
||||||
|
unsigned int height;
|
||||||
|
unsigned int ncolors;
|
||||||
|
unsigned int cpp;
|
||||||
|
XpmColor *colorTable;
|
||||||
|
xpmHashTable *hashtable;
|
||||||
|
unsigned int **pixels;
|
||||||
{
|
{
|
||||||
unsigned int *iptr, *iptr2;
|
unsigned int *iptr, *iptr2;
|
||||||
unsigned int a, x, y;
|
unsigned int a, x, y;
|
||||||
@@ -487,15 +363,15 @@ ParsePixels(xpmData *data, unsigned int width, unsigned int height, unsigned int
|
|||||||
|
|
||||||
bzero((char *)colidx, 256 * sizeof(short));
|
bzero((char *)colidx, 256 * sizeof(short));
|
||||||
for (a = 0; a < ncolors; a++)
|
for (a = 0; a < ncolors; a++)
|
||||||
colidx[colorTable[a].string[0]] = a + 1;
|
colidx[(unsigned char)colorTable[a].string[0]] = a + 1;
|
||||||
|
|
||||||
for (y = 0; y < height; y++) {
|
for (y = 0; y < height; y++) {
|
||||||
xpmNextString(data);
|
xpmNextString(data);
|
||||||
for (x = 0; x < width; x++, iptr++) {
|
for (x = 0; x < width; x++, iptr++) {
|
||||||
int idx = colidx[xpmGetC(data)];
|
int c = xpmGetC(data);
|
||||||
|
|
||||||
if (idx != 0)
|
if (c > 0 && c < 256 && colidx[c] != 0)
|
||||||
*iptr = idx - 1;
|
*iptr = colidx[c] - 1;
|
||||||
else {
|
else {
|
||||||
XpmFree(iptr2);
|
XpmFree(iptr2);
|
||||||
return (XpmFileInvalid);
|
return (XpmFileInvalid);
|
||||||
@@ -529,18 +405,24 @@ if (cidx[f]) XpmFree(cidx[f]);}
|
|||||||
return (XpmNoMemory);
|
return (XpmNoMemory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cidx[char1][colorTable[a].string[1]] = a + 1;
|
cidx[char1][(unsigned char)colorTable[a].string[1]] = a + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (y = 0; y < height; y++) {
|
for (y = 0; y < height; y++) {
|
||||||
xpmNextString(data);
|
xpmNextString(data);
|
||||||
for (x = 0; x < width; x++, iptr++) {
|
for (x = 0; x < width; x++, iptr++) {
|
||||||
int cc1 = xpmGetC(data);
|
int cc1 = xpmGetC(data);
|
||||||
int idx = cidx[cc1][xpmGetC(data)];
|
if (cc1 > 0 && cc1 < 256) {
|
||||||
|
int cc2 = xpmGetC(data);
|
||||||
if (idx != 0)
|
if (cc2 > 0 && cc2 < 256 &&
|
||||||
*iptr = idx - 1;
|
cidx[cc1] && cidx[cc1][cc2] != 0)
|
||||||
else {
|
*iptr = cidx[cc1][cc2] - 1;
|
||||||
|
else {
|
||||||
|
FREE_CIDX;
|
||||||
|
XpmFree(iptr2);
|
||||||
|
return (XpmFileInvalid);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
FREE_CIDX;
|
FREE_CIDX;
|
||||||
XpmFree(iptr2);
|
XpmFree(iptr2);
|
||||||
return (XpmFileInvalid);
|
return (XpmFileInvalid);
|
||||||
@@ -598,8 +480,11 @@ if (cidx[f]) XpmFree(cidx[f]);}
|
|||||||
return (XpmSuccess);
|
return (XpmSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int
|
||||||
ParseExtensions(xpmData *data, XpmExtension **extensions, unsigned int *nextensions)
|
xpmParseExtensions(data, extensions, nextensions)
|
||||||
|
xpmData *data;
|
||||||
|
XpmExtension **extensions;
|
||||||
|
unsigned int *nextensions;
|
||||||
{
|
{
|
||||||
XpmExtension *exts = NULL, *ext;
|
XpmExtension *exts = NULL, *ext;
|
||||||
unsigned int num = 0;
|
unsigned int num = 0;
|
||||||
@@ -703,3 +588,158 @@ ParseExtensions(xpmData *data, XpmExtension **extensions, unsigned int *nextensi
|
|||||||
*extensions = exts;
|
*extensions = exts;
|
||||||
return (XpmSuccess);
|
return (XpmSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* function call in case of error */
|
||||||
|
#undef RETURN
|
||||||
|
#define RETURN(status) \
|
||||||
|
{ \
|
||||||
|
goto error; \
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function parses an Xpm file or data and store the found informations
|
||||||
|
* in an an XpmImage structure which is returned.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xpmParseData(data, image, info)
|
||||||
|
xpmData *data;
|
||||||
|
XpmImage *image;
|
||||||
|
XpmInfo *info;
|
||||||
|
{
|
||||||
|
/* variables to return */
|
||||||
|
unsigned int width, height, ncolors, cpp;
|
||||||
|
unsigned int x_hotspot, y_hotspot, hotspot = 0, extensions = 0;
|
||||||
|
XpmColor *colorTable = NULL;
|
||||||
|
unsigned int *pixelindex = NULL;
|
||||||
|
char *hints_cmt = NULL;
|
||||||
|
char *colors_cmt = NULL;
|
||||||
|
char *pixels_cmt = NULL;
|
||||||
|
|
||||||
|
unsigned int cmts;
|
||||||
|
int ErrorStatus;
|
||||||
|
xpmHashTable hashtable;
|
||||||
|
|
||||||
|
cmts = info && (info->valuemask & XpmReturnComments);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* parse the header
|
||||||
|
*/
|
||||||
|
ErrorStatus = xpmParseHeader(data);
|
||||||
|
if (ErrorStatus != XpmSuccess)
|
||||||
|
return (ErrorStatus);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* read values
|
||||||
|
*/
|
||||||
|
ErrorStatus = xpmParseValues(data, &width, &height, &ncolors, &cpp,
|
||||||
|
&x_hotspot, &y_hotspot, &hotspot,
|
||||||
|
&extensions);
|
||||||
|
if (ErrorStatus != XpmSuccess)
|
||||||
|
return (ErrorStatus);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* store the hints comment line
|
||||||
|
*/
|
||||||
|
if (cmts)
|
||||||
|
xpmGetCmt(data, &hints_cmt);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* init the hastable
|
||||||
|
*/
|
||||||
|
if (USE_HASHTABLE) {
|
||||||
|
ErrorStatus = xpmHashTableInit(&hashtable);
|
||||||
|
if (ErrorStatus != XpmSuccess)
|
||||||
|
return (ErrorStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* read colors
|
||||||
|
*/
|
||||||
|
ErrorStatus = xpmParseColors(data, ncolors, cpp, &colorTable, &hashtable);
|
||||||
|
if (ErrorStatus != XpmSuccess) {
|
||||||
|
if (USE_HASHTABLE)
|
||||||
|
xpmHashTableFree(&hashtable);
|
||||||
|
RETURN(ErrorStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* store the colors comment line
|
||||||
|
*/
|
||||||
|
if (cmts)
|
||||||
|
xpmGetCmt(data, &colors_cmt);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* read pixels and index them on color number
|
||||||
|
*/
|
||||||
|
ErrorStatus = ParsePixels(data, width, height, ncolors, cpp, colorTable,
|
||||||
|
&hashtable, &pixelindex);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* free the hastable
|
||||||
|
*/
|
||||||
|
if (USE_HASHTABLE)
|
||||||
|
xpmHashTableFree(&hashtable);
|
||||||
|
|
||||||
|
if (ErrorStatus != XpmSuccess)
|
||||||
|
RETURN(ErrorStatus);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* store the pixels comment line
|
||||||
|
*/
|
||||||
|
if (cmts)
|
||||||
|
xpmGetCmt(data, &pixels_cmt);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* parse extensions
|
||||||
|
*/
|
||||||
|
if (info && (info->valuemask & XpmReturnExtensions))
|
||||||
|
if (extensions) {
|
||||||
|
ErrorStatus = xpmParseExtensions(data, &info->extensions,
|
||||||
|
&info->nextensions);
|
||||||
|
if (ErrorStatus != XpmSuccess)
|
||||||
|
RETURN(ErrorStatus);
|
||||||
|
} else {
|
||||||
|
info->extensions = NULL;
|
||||||
|
info->nextensions = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* store found informations in the XpmImage structure
|
||||||
|
*/
|
||||||
|
image->width = width;
|
||||||
|
image->height = height;
|
||||||
|
image->cpp = cpp;
|
||||||
|
image->ncolors = ncolors;
|
||||||
|
image->colorTable = colorTable;
|
||||||
|
image->data = pixelindex;
|
||||||
|
|
||||||
|
if (info) {
|
||||||
|
if (cmts) {
|
||||||
|
info->hints_cmt = hints_cmt;
|
||||||
|
info->colors_cmt = colors_cmt;
|
||||||
|
info->pixels_cmt = pixels_cmt;
|
||||||
|
}
|
||||||
|
if (hotspot) {
|
||||||
|
info->x_hotspot = x_hotspot;
|
||||||
|
info->y_hotspot = y_hotspot;
|
||||||
|
info->valuemask |= XpmHotspot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (XpmSuccess);
|
||||||
|
|
||||||
|
/* exit point in case of error, free only locally allocated variables */
|
||||||
|
error:
|
||||||
|
if (colorTable)
|
||||||
|
xpmFreeColorTable(colorTable, ncolors);
|
||||||
|
if (pixelindex)
|
||||||
|
XpmFree(pixelindex);
|
||||||
|
if (hints_cmt)
|
||||||
|
XpmFree(hints_cmt);
|
||||||
|
if (colors_cmt)
|
||||||
|
XpmFree(colors_cmt);
|
||||||
|
if (pixels_cmt)
|
||||||
|
XpmFree(pixels_cmt);
|
||||||
|
|
||||||
|
return(ErrorStatus);
|
||||||
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************\
|
/*****************************************************************************\
|
||||||
* XpmRdFToData.c: *
|
* RdFToDat.c: *
|
||||||
* *
|
* *
|
||||||
* XPM library *
|
* XPM library *
|
||||||
* Parse an XPM file and create an array of strings corresponding to it. *
|
* Parse an XPM file and create an array of strings corresponding to it. *
|
||||||
@@ -32,10 +32,12 @@
|
|||||||
* Developed by Dan Greening dgreen@cs.ucla.edu / dgreen@sti.com *
|
* Developed by Dan Greening dgreen@cs.ucla.edu / dgreen@sti.com *
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
#include "xpm34p.h"
|
#include "XpmI.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
XpmReadFileToData(char *filename, char ***data_return)
|
XpmReadFileToData(filename, data_return)
|
||||||
|
char *filename;
|
||||||
|
char ***data_return;
|
||||||
{
|
{
|
||||||
XpmImage image;
|
XpmImage image;
|
||||||
XpmInfo info;
|
XpmInfo info;
|
||||||
|
167
src/xpm/rdftoi.c
167
src/xpm/rdftoi.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************\
|
/*****************************************************************************\
|
||||||
* XpmRdFToI.c: *
|
* RdFToI.c: *
|
||||||
* *
|
* *
|
||||||
* XPM library *
|
* XPM library *
|
||||||
* Parse an XPM file and create the image and possibly its mask *
|
* Parse an XPM file and create the image and possibly its mask *
|
||||||
@@ -32,36 +32,61 @@
|
|||||||
* Developed by Arnaud Le Hors *
|
* Developed by Arnaud Le Hors *
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
#include "xpm34p.h"
|
#include "XpmI.h"
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#if !defined(NO_ZPIPE) && defined(WIN32)
|
||||||
|
# define popen _popen
|
||||||
|
# define pclose _pclose
|
||||||
|
# if defined(STAT_ZFILE)
|
||||||
|
# include <io.h>
|
||||||
|
# define stat _stat
|
||||||
|
# define fstat _fstat
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
LFUNC(OpenReadFile, int, (char *filename, xpmData *mdata));
|
||||||
|
LFUNC(xpmDataClose, void, (xpmData *mdata));
|
||||||
|
|
||||||
|
#ifndef CXPMPROG
|
||||||
int
|
int
|
||||||
XpmReadFileToImage(Display *display, char *filename,
|
XpmReadFileToImage(display, filename,
|
||||||
XImage **image_return, XImage **shapeimage_return, XpmAttributes *attributes)
|
image_return, shapeimage_return, attributes)
|
||||||
|
Display *display;
|
||||||
|
char *filename;
|
||||||
|
XImage **image_return;
|
||||||
|
XImage **shapeimage_return;
|
||||||
|
XpmAttributes *attributes;
|
||||||
{
|
{
|
||||||
XpmImage image;
|
XpmImage image;
|
||||||
XpmInfo info;
|
XpmInfo info;
|
||||||
int ErrorStatus;
|
int ErrorStatus;
|
||||||
|
xpmData mdata;
|
||||||
|
|
||||||
/* create an XpmImage from the file */
|
xpmInitXpmImage(&image);
|
||||||
|
xpmInitXpmInfo(&info);
|
||||||
|
|
||||||
|
/* open file to read */
|
||||||
|
if ((ErrorStatus = OpenReadFile(filename, &mdata)) != XpmSuccess)
|
||||||
|
return (ErrorStatus);
|
||||||
|
|
||||||
|
/* create the XImage from the XpmData */
|
||||||
if (attributes) {
|
if (attributes) {
|
||||||
xpmInitAttributes(attributes);
|
xpmInitAttributes(attributes);
|
||||||
xpmSetInfoMask(&info, attributes);
|
xpmSetInfoMask(&info, attributes);
|
||||||
ErrorStatus = XpmReadFileToXpmImage(filename, &image, &info);
|
ErrorStatus = xpmParseDataAndCreate(display, &mdata,
|
||||||
|
image_return, shapeimage_return,
|
||||||
|
&image, &info, attributes);
|
||||||
} else
|
} else
|
||||||
ErrorStatus = XpmReadFileToXpmImage(filename, &image, NULL);
|
ErrorStatus = xpmParseDataAndCreate(display, &mdata,
|
||||||
|
image_return, shapeimage_return,
|
||||||
if (ErrorStatus != XpmSuccess)
|
&image, NULL, attributes);
|
||||||
return (ErrorStatus);
|
|
||||||
|
|
||||||
/* create the related ximages */
|
|
||||||
ErrorStatus = XpmCreateImageFromXpmImage(display, &image,
|
|
||||||
image_return, shapeimage_return,
|
|
||||||
attributes);
|
|
||||||
if (attributes) {
|
if (attributes) {
|
||||||
if (ErrorStatus >= 0) /* no fatal error */
|
if (ErrorStatus >= 0) /* no fatal error */
|
||||||
xpmSetAttributes(attributes, &image, &info);
|
xpmSetAttributes(attributes, &image, &info);
|
||||||
XpmFreeXpmInfo(&info);
|
XpmFreeXpmInfo(&info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xpmDataClose(&mdata);
|
||||||
/* free the XpmImage */
|
/* free the XpmImage */
|
||||||
XpmFreeXpmImage(&image);
|
XpmFreeXpmImage(&image);
|
||||||
|
|
||||||
@@ -69,7 +94,10 @@ XpmReadFileToImage(Display *display, char *filename,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
XpmReadFileToXpmImage(char *filename, XpmImage *image, XpmInfo *info)
|
XpmReadFileToXpmImage(filename, image, info)
|
||||||
|
char *filename;
|
||||||
|
XpmImage *image;
|
||||||
|
XpmInfo *info;
|
||||||
{
|
{
|
||||||
xpmData mdata;
|
xpmData mdata;
|
||||||
int ErrorStatus;
|
int ErrorStatus;
|
||||||
@@ -79,7 +107,7 @@ XpmReadFileToXpmImage(char *filename, XpmImage *image, XpmInfo *info)
|
|||||||
xpmInitXpmInfo(info);
|
xpmInitXpmInfo(info);
|
||||||
|
|
||||||
/* open file to read */
|
/* open file to read */
|
||||||
if ((ErrorStatus = xpmReadFile(filename, &mdata)) != XpmSuccess)
|
if ((ErrorStatus = OpenReadFile(filename, &mdata)) != XpmSuccess)
|
||||||
return (ErrorStatus);
|
return (ErrorStatus);
|
||||||
|
|
||||||
/* create the XpmImage from the XpmData */
|
/* create the XpmImage from the XpmData */
|
||||||
@@ -89,3 +117,106 @@ XpmReadFileToXpmImage(char *filename, XpmImage *image, XpmInfo *info)
|
|||||||
|
|
||||||
return (ErrorStatus);
|
return (ErrorStatus);
|
||||||
}
|
}
|
||||||
|
#endif /* CXPMPROG */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* open the given file to be read as an xpmData which is returned.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
OpenReadFile(filename, mdata)
|
||||||
|
char *filename;
|
||||||
|
xpmData *mdata;
|
||||||
|
{
|
||||||
|
#ifndef NO_ZPIPE
|
||||||
|
char *compressfile, buf[BUFSIZ];
|
||||||
|
# ifdef STAT_ZFILE
|
||||||
|
struct stat status;
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!filename) {
|
||||||
|
mdata->stream.file = (stdin);
|
||||||
|
mdata->type = XPMFILE;
|
||||||
|
} else {
|
||||||
|
#ifndef NO_ZPIPE
|
||||||
|
int len = strlen(filename);
|
||||||
|
if ((len > 2) && !strcmp(".Z", filename + (len - 2))) {
|
||||||
|
mdata->type = XPMPIPE;
|
||||||
|
sprintf(buf, "uncompress -c \"%s\"", filename);
|
||||||
|
if (!(mdata->stream.file = popen(buf, "r")))
|
||||||
|
return (XpmOpenFailed);
|
||||||
|
|
||||||
|
} else if ((len > 3) && !strcmp(".gz", filename + (len - 3))) {
|
||||||
|
mdata->type = XPMPIPE;
|
||||||
|
sprintf(buf, "gunzip -qc \"%s\"", filename);
|
||||||
|
if (!(mdata->stream.file = popen(buf, "r")))
|
||||||
|
return (XpmOpenFailed);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
# ifdef STAT_ZFILE
|
||||||
|
if (!(compressfile = (char *) XpmMalloc(len + 4)))
|
||||||
|
return (XpmNoMemory);
|
||||||
|
|
||||||
|
sprintf(compressfile, "%s.Z", filename);
|
||||||
|
if (!stat(compressfile, &status)) {
|
||||||
|
sprintf(buf, "uncompress -c \"%s\"", compressfile);
|
||||||
|
if (!(mdata->stream.file = popen(buf, "r"))) {
|
||||||
|
XpmFree(compressfile);
|
||||||
|
return (XpmOpenFailed);
|
||||||
|
}
|
||||||
|
mdata->type = XPMPIPE;
|
||||||
|
} else {
|
||||||
|
sprintf(compressfile, "%s.gz", filename);
|
||||||
|
if (!stat(compressfile, &status)) {
|
||||||
|
sprintf(buf, "gunzip -c \"%s\"", compressfile);
|
||||||
|
if (!(mdata->stream.file = popen(buf, "r"))) {
|
||||||
|
XpmFree(compressfile);
|
||||||
|
return (XpmOpenFailed);
|
||||||
|
}
|
||||||
|
mdata->type = XPMPIPE;
|
||||||
|
} else {
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
if (!(mdata->stream.file = fopen(filename, "r"))) {
|
||||||
|
#if !defined(NO_ZPIPE) && defined(STAT_ZFILE)
|
||||||
|
XpmFree(compressfile);
|
||||||
|
#endif
|
||||||
|
return (XpmOpenFailed);
|
||||||
|
}
|
||||||
|
mdata->type = XPMFILE;
|
||||||
|
#ifndef NO_ZPIPE
|
||||||
|
# ifdef STAT_ZFILE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XpmFree(compressfile);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
mdata->CommentLength = 0;
|
||||||
|
#ifdef CXPMPROG
|
||||||
|
mdata->lineNum = 0;
|
||||||
|
mdata->charNum = 0;
|
||||||
|
#endif
|
||||||
|
return (XpmSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* close the file related to the xpmData if any
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
xpmDataClose(mdata)
|
||||||
|
xpmData *mdata;
|
||||||
|
{
|
||||||
|
switch (mdata->type) {
|
||||||
|
case XPMFILE:
|
||||||
|
if (mdata->stream.file != (stdin))
|
||||||
|
fclose(mdata->stream.file);
|
||||||
|
break;
|
||||||
|
#ifndef NO_ZPIPE
|
||||||
|
case XPMPIPE:
|
||||||
|
pclose(mdata->stream.file);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
192
src/xpm/readme
192
src/xpm/readme
@@ -1,192 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
303
src/xpm/readme.htm
Normal file
303
src/xpm/readme.htm
Normal file
@@ -0,0 +1,303 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||||
|
<html lang="en">
|
||||||
|
<HEAD>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||||
|
<TITLE>XPM README</TITLE>
|
||||||
|
</HEAD>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1 align="center">XPM README</h1>
|
||||||
|
|
||||||
|
<h2>Contents</h2>
|
||||||
|
|
||||||
|
<ol>
|
||||||
|
<li><a href="#sec1">What Is XPM?</a>
|
||||||
|
<li><a href="#sec2">Where to get XPM?</a>
|
||||||
|
<li><a href="#sec3">Documentation</a>
|
||||||
|
<li><a href="#sec4">Installation</a>
|
||||||
|
<ol>
|
||||||
|
<li><a href="#sec4.1">With imake</a>
|
||||||
|
<li><a href="#sec4.2">Without imake</a>
|
||||||
|
</ol>
|
||||||
|
<li><a href="#sec5">SXPM</a>
|
||||||
|
<li><a href="#sec6">CXPM</a>
|
||||||
|
<li><a href="#sec7">Other Tools</a>
|
||||||
|
<li><a href="#sec8">Discussion</a>
|
||||||
|
<li><a href="#copy">Copyright</a>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a name="sec1">1. What Is XPM?</a></h2>
|
||||||
|
<p>
|
||||||
|
XPM (X PixMap) is a format for storing/retrieving X pixmaps to/from files.
|
||||||
|
<p>
|
||||||
|
Here is provided a library containing a set of four functions, similar to the
|
||||||
|
X bitmap functions as defined in the Xlib: <code>XpmCreatePixmapFromData</code>,
|
||||||
|
<code>XpmCreateDataFromPixmap</code>, <code>XpmReadFileToPixmap</code> and <code>XpmWriteFileFromPixmap</code> for
|
||||||
|
respectively including, storing, reading and writing this format, plus four
|
||||||
|
other: <code>XpmCreateImageFromData</code>, <code>XpmCreateDataFromImage</code>, <code>XpmReadFileToImage</code> and
|
||||||
|
<code>XpmWriteFileFromImage</code> for working with images instead of pixmaps.
|
||||||
|
<p>
|
||||||
|
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.
|
||||||
|
<p>
|
||||||
|
See the XPM Manual for details.
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a name="sec2">2. Where to get XPM?</a></h2>
|
||||||
|
<p>
|
||||||
|
New XPM updates are announced on the comp.windows.x newsgroup, and on the
|
||||||
|
"xpm-talk" list and you can always consult the XPM Home page at <a
|
||||||
|
href="http://www.inria.fr/koala/lehors/xpm.html">http://www.inria.fr/koala/lehors/xpm.html</a>
|
||||||
|
<p>The latest "official" XPM release can always be found at:
|
||||||
|
<br>Boston, USA: <a
|
||||||
|
href="ftp://ftp.x.org/contrib">ftp://ftp.x.org/contrib</a>
|
||||||
|
<br>Sophia Antipolis, France: <a
|
||||||
|
href="ftp://koala.inria.fr/pub/xpm">ftp://koala.inria.fr/pub/xpm</a>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a name="sec3">3. Documentation</a></h2>
|
||||||
|
<p>
|
||||||
|
Old users might read the <a href="CHANGES">CHANGES</a> file for a history
|
||||||
|
of changes interesting the user.
|
||||||
|
<p>
|
||||||
|
Read the doc. The documentation is in PostScript format (<a
|
||||||
|
href="doc/xpm.PS">doc/xpm.PS</a>) and has been produced with
|
||||||
|
FrameMaker. The source files are available on request.
|
||||||
|
<p>
|
||||||
|
A <a href="FAQ.html">FAQ</a> (Frequently Asked Questions) is also provided,
|
||||||
|
so if you experience any problem you should have a look at this file.
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a name="sec4">4. Installation</a></h2>
|
||||||
|
<p>
|
||||||
|
To obtain the XPM library, first uncompress and untar the compressed tar file
|
||||||
|
in an appropriate directory.
|
||||||
|
<p>
|
||||||
|
Then you can either compile XPM via "imake" or in a stand-alone way.
|
||||||
|
|
||||||
|
<h3><a name="sec4.1">4.1. With imake</a></h3>
|
||||||
|
<p>
|
||||||
|
Imakefiles are provided to build both shared and unshared libraries.
|
||||||
|
However, building a shared lib is very OS dependent and often requires
|
||||||
|
specific files which are not available. Also config files are often not
|
||||||
|
set correctly for this task. So if it fails you can avoid trying to
|
||||||
|
build one and simply build the static library instead. In order to do
|
||||||
|
so you should edit the top Imakefile to add -DSharedLibXpm=NO to the
|
||||||
|
definition of IMAKE_DEFINES as described.
|
||||||
|
<p>
|
||||||
|
The compilation and installation of the library and the sxpm program
|
||||||
|
should only require you to edit the top Imakefile. But you should do so
|
||||||
|
in order to specify the locations where the various files should be
|
||||||
|
installed and to set the DEFINES variable accordingly to your system.
|
||||||
|
<p>
|
||||||
|
On Solaris 2.* the compilation works only in the native svr4
|
||||||
|
environment, avoid the bsd one or it won't compile. Especially you
|
||||||
|
should be using /opt/SUNWspro/bin/cc and not /usr/ucb/cc.
|
||||||
|
Also since the compiler is no longer part of the OS distribution a lot
|
||||||
|
of people use gcc instead. This is fine, but be aware that the imake
|
||||||
|
tool you get as part of the X Window System on a solaris box is
|
||||||
|
configured for cc. Therefore the compilation using the generated
|
||||||
|
Makefiles will not succeed unless you have changed the default
|
||||||
|
configuration. An easy work around is to directly edit the generated
|
||||||
|
lib/Makefile to change '-K pic' to '-fpic'. Fixing your imake
|
||||||
|
configuration would be better though.
|
||||||
|
<p>
|
||||||
|
On Linux, if you do not use ELF yet you'd better get the binary
|
||||||
|
distribution available from sunsite. Because it's really a pain to
|
||||||
|
build a shared lib and the current XPM distribution doesn't contain
|
||||||
|
the jump files you would need to do so. On the other hand people have
|
||||||
|
had no problems building it using ELF.
|
||||||
|
<p>
|
||||||
|
Then execute the following command:
|
||||||
|
<pre>
|
||||||
|
xmkmf -a
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
or if this option is not supported by your version of xmkmf:
|
||||||
|
<pre>
|
||||||
|
xmkmf
|
||||||
|
make Makefiles
|
||||||
|
make includes
|
||||||
|
make depend (optional)
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
Then simply execute:
|
||||||
|
<pre>
|
||||||
|
make
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
which will build the XPM library and the sxpm application.
|
||||||
|
Then do:
|
||||||
|
<pre>
|
||||||
|
make install
|
||||||
|
make install.man
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
which will install the library and the sxpm program and man page.
|
||||||
|
<p>
|
||||||
|
If it fails, be sure you have set the DEFINES correctly in the top
|
||||||
|
Imakefile to suit your machine.
|
||||||
|
|
||||||
|
<h4>NOTE ON USING IMAKE:</h4>
|
||||||
|
<p>
|
||||||
|
Building the XPM distribution with imake requires to have imake
|
||||||
|
<strong>correctly installed and configured</strong> on your
|
||||||
|
system. I do my best at tweaking the Imakefiles so they work with
|
||||||
|
as many imake flavors people might have as possible but there is
|
||||||
|
nothing I can do against wrong imake configurations. So if your
|
||||||
|
build fails using imake, don't send me email for advice. Get your
|
||||||
|
imake configuration fixed or forget about it!
|
||||||
|
|
||||||
|
|
||||||
|
<h3><a name="sec4.2">4.2. Without imake</a></h3>
|
||||||
|
<p>
|
||||||
|
A set of makefiles is provided for those who do not have imake
|
||||||
|
available on their system. However, this is only provided as a
|
||||||
|
convenience and you should be considered as a starting point and not as
|
||||||
|
something ready to use. These makefiles, called Makefile.noX, will most
|
||||||
|
likely require some editing in order be set accordingly to your system.
|
||||||
|
<p>
|
||||||
|
Once this setting is done, you should be able to compile XPM, by
|
||||||
|
executing the following command:
|
||||||
|
<pre>
|
||||||
|
make -f Makefile.noX
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
Then to install it, do:
|
||||||
|
<pre>
|
||||||
|
make -f Makefile.noX install
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a name="sec5">5. SXPM</a></h2>
|
||||||
|
<p>
|
||||||
|
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 already have it, otherwise just do:
|
||||||
|
<pre>
|
||||||
|
cd sxpm; make
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
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.
|
||||||
|
<p>
|
||||||
|
By executing 'sxpm -help' you will get the usage.
|
||||||
|
<p>
|
||||||
|
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.
|
||||||
|
<p>
|
||||||
|
Executing 'sxpm -plaid -sc lines_in_mix blue' will show the feature of
|
||||||
|
overriding color symbols giving a colorname, executing 'sxpm -plaid -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.
|
||||||
|
<p>
|
||||||
|
Then you should try 'sxpm -plaid -o output' to get an output file using the
|
||||||
|
XpmWriteFileFromPixmap function.
|
||||||
|
<p>
|
||||||
|
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.
|
||||||
|
<p>
|
||||||
|
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.
|
||||||
|
<p>
|
||||||
|
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.
|
||||||
|
<p>
|
||||||
|
To end look at plaid_ext.xpm and try "sxpm -nod plaid_ext.xpm -v" to see how
|
||||||
|
extensions are handled.
|
||||||
|
<p>
|
||||||
|
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.
|
||||||
|
<p>
|
||||||
|
See the manual page for more detail.
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a name="sec6">6. CXPM</a></h2>
|
||||||
|
<p>
|
||||||
|
The cxpm tool is provided to help you figure out whether an XPM file is correct
|
||||||
|
or not with regard to its format. If you have previously done 'make' or
|
||||||
|
'make all' you should already have it, otherwise just do:
|
||||||
|
<pre>
|
||||||
|
cd cxpm; make
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
The related man page will tell you everything about it but here is a simple
|
||||||
|
example of what it does:
|
||||||
|
<pre>
|
||||||
|
$ ./cxpm bogus_pixmap
|
||||||
|
Xpm Error: Invalid XPM file.
|
||||||
|
Error found line 3 near character 5
|
||||||
|
</pre>
|
||||||
|
<p>
|
||||||
|
It is pretty limited but at least, unlike sxpm, it gives you some hint on where
|
||||||
|
the error occured within the file.
|
||||||
|
|
||||||
|
|
||||||
|
<h2><a name="sec7">7. Other Tools</a></h2>
|
||||||
|
<p>
|
||||||
|
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.
|
||||||
|
|
||||||
|
<h2><a name="sec8">8. Discussion</a></h2>
|
||||||
|
<p>
|
||||||
|
There is a mailing list to discuss about XPM which is <a
|
||||||
|
href="mailto:xpm-talk@sophia.inria.fr">xpm-talk@sophia.inria.fr</a>.
|
||||||
|
Any request to subscribe should be sent to <a
|
||||||
|
href="mailto:xpm-talk-request@sophia.inria.fr">xpm-talk-request@sophia.inria.fr</a>.
|
||||||
|
The archive of the xpm-talk list is available through the web at
|
||||||
|
<a
|
||||||
|
href="http://zenon.inria.fr/koala/xpm-talk-hypermail">http://zenon.inria.fr/koala/xpm-talk-hypermail</a>
|
||||||
|
and through ftp at <a
|
||||||
|
href="ftp://koala.inria.fr/pub/xpm/xpm-talk-archive">ftp://koala.inria.fr/pub/xpm/xpm-talk-archive</a>
|
||||||
|
<p>
|
||||||
|
Please mail any bug reports or modifications done, comments, suggestions,
|
||||||
|
requests for updates or patches to port on another machine to:
|
||||||
|
|
||||||
|
<p>Email: <a href="lehors@sophia.inria.fr">lehors@sophia.inria.fr</a>
|
||||||
|
<br>Phone: +33 (0)4 93 65 78 89
|
||||||
|
<br>Surface Mail:<br>
|
||||||
|
Arnaud Le Hors<br>
|
||||||
|
Inria BP.93<br>
|
||||||
|
2004, Route des lucioles<br>
|
||||||
|
06902 Sophia Antipolis Cedex<br>
|
||||||
|
FRANCE
|
||||||
|
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
<h2><a name="copy">Copyright (C) 1989-95 GROUPE BULL</a></h2>
|
||||||
|
<p>
|
||||||
|
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:
|
||||||
|
<p>
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
<p>
|
||||||
|
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.
|
||||||
|
<p>
|
||||||
|
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.
|
||||||
|
</body>
|
@@ -5,9 +5,9 @@ README.MSW hedu@cul-ipn.uni-kiel.de 5/94
|
|||||||
|
|
||||||
Motivated by the wxWindows library, which is a (freely available) toolkit
|
Motivated by the wxWindows library, which is a (freely available) toolkit
|
||||||
for developing multi-platform, graphical applications from the same body
|
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
|
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.
|
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.
|
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
|
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
|
a kind of beta. But it should be possible to run it as a simple libxpm.a
|
||||||
@@ -57,7 +57,7 @@ Neither a special API for MSW nor a special MSW documentation other than this.
|
|||||||
|
|
||||||
INSTALLATION:
|
INSTALLATION:
|
||||||
There is not yet a makefile with it. Simply take all the *.c files
|
There is not yet a makefile with it. Simply take all the *.c files
|
||||||
into your project.
|
into your project except the files related to Pixmap operations: *P*.c.
|
||||||
!!!You MUST set FOR_MSW on the preprocessor options!!!
|
!!!You MUST set FOR_MSW on the preprocessor options!!!
|
||||||
(You might uncomment NEED_STRCASECMP in xpm.h if it's in your lib)
|
(You might uncomment NEED_STRCASECMP in xpm.h if it's in your lib)
|
||||||
This should compile into libxpm.a. Good luck...
|
This should compile into libxpm.a. Good luck...
|
||||||
@@ -74,6 +74,50 @@ wxxpm, XPM support for wxWindows, the latest version is available at
|
|||||||
|
|
||||||
Please contact me if you have suggestions, comments or problems!
|
Please contact me if you have suggestions, comments or problems!
|
||||||
|
|
||||||
|
================================================================
|
||||||
|
Some fixes and comments by Jan Wielemaker (jan@swi.psy.uva.nl),
|
||||||
|
Oct 24, 1996:
|
||||||
|
|
||||||
|
* Please try not to disturb me on this, XPM is not my
|
||||||
|
piece of cake.
|
||||||
|
|
||||||
|
* Hermann Dunkel has appearently moved in virtual space.
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
* I've used the xpm package under NT 4.0 and MSVC++ 4.2.
|
||||||
|
|
||||||
|
* I've made a big performance improvement in
|
||||||
|
ParseAndPutPixels(), fixed creation of the mask in
|
||||||
|
SetColor() in create.c. I looked into XCreateImage()
|
||||||
|
in simx.c, but commented out my improvement for reasons
|
||||||
|
you'll find there. If you know what is going on, statement
|
||||||
|
(1) does not apply to you.
|
||||||
|
|
||||||
|
Comments on installation:
|
||||||
|
|
||||||
|
* Donot include the to/from pixmap files into the project.
|
||||||
|
These are the ones containing a capital P somewhere in their
|
||||||
|
name. You can also first include all, and then remove all
|
||||||
|
the files you get errors on :-)
|
||||||
|
|
||||||
|
* The DC that is requested should be a valid memory DC, thus
|
||||||
|
CreateCompatibleDC(NULL) provides a good generic one, but
|
||||||
|
GetDC(NULL) doesn't! This costed me some time.
|
||||||
|
|
||||||
|
* The real difficulty is using the mask, mostly due to the
|
||||||
|
bad documentation. If 95 or NT is your target, use:
|
||||||
|
|
||||||
|
MaskBlt(context.hdc, // Destination DC
|
||||||
|
x, y, w, h, // Destination area
|
||||||
|
mhdc, // Memory DC with the image selected
|
||||||
|
sx, sy, // Source X,Y
|
||||||
|
msk, // HBITMAP of the mask
|
||||||
|
sx, sy, // Mask X,Y
|
||||||
|
MAKEROP4(SRCPAINT, SRCCOPY)); // The magic op code.
|
||||||
|
================================================================
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
////|\\\\ \\\\\\ Hermann Dunkel
|
////|\\\\ \\\\\\ Hermann Dunkel
|
||||||
O O ////// IPN Uni Kiel, Germany
|
O O ////// IPN Uni Kiel, Germany
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -42,18 +42,8 @@
|
|||||||
* W. Snitily but has been modified for my special need
|
* W. Snitily but has been modified for my special need
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "xpm34p.h"
|
#include "XpmI.h"
|
||||||
#ifdef VMS
|
|
||||||
#include "sys$library:ctype.h"
|
|
||||||
#include "sys$library:string.h"
|
|
||||||
#else
|
|
||||||
#include <ctype.h>
|
#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
|
#ifndef FOR_MSW /* normal part first, MSW part at
|
||||||
* the end, (huge ifdef!) */
|
* the end, (huge ifdef!) */
|
||||||
@@ -63,11 +53,14 @@
|
|||||||
* number of entries stored.
|
* number of entries stored.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xpmReadRgbNames(char *rgb_fname, xpmRgbName rgbn[])
|
xpmReadRgbNames(rgb_fname, rgbn)
|
||||||
|
char *rgb_fname;
|
||||||
|
xpmRgbName rgbn[];
|
||||||
|
|
||||||
{
|
{
|
||||||
FILE *rgbf;
|
FILE *rgbf;
|
||||||
int i, items, red, green, blue;
|
int n, items, red, green, blue;
|
||||||
char line[512], name[512], *rgbname, *n, *m;
|
char line[512], name[512], *rgbname, *s1, *s2;
|
||||||
xpmRgbName *rgb;
|
xpmRgbName *rgb;
|
||||||
|
|
||||||
/* Open the rgb text file. Abort if error. */
|
/* Open the rgb text file. Abort if error. */
|
||||||
@@ -75,19 +68,15 @@ xpmReadRgbNames(char *rgb_fname, xpmRgbName rgbn[])
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Loop reading each line in the file. */
|
/* Loop reading each line in the file. */
|
||||||
for (i = 0, rgb = rgbn; fgets(line, sizeof(line), rgbf); i++, rgb++) {
|
n = 0;
|
||||||
|
rgb = rgbn;
|
||||||
|
/* Quit if rgb text file has too many entries. */
|
||||||
|
while (fgets(line, sizeof(line), rgbf) && n < MAX_RGBNAMES) {
|
||||||
|
|
||||||
/* Quit if rgb text file is too large. */
|
/* Skip silently if line is bad. */
|
||||||
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);
|
items = sscanf(line, "%d %d %d %[^\n]\n", &red, &green, &blue, name);
|
||||||
if (items != 4) {
|
if (items != 4)
|
||||||
i--;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure rgb values are within 0->255 range. Skip silently if
|
* Make sure rgb values are within 0->255 range. Skip silently if
|
||||||
@@ -95,40 +84,41 @@ xpmReadRgbNames(char *rgb_fname, xpmRgbName rgbn[])
|
|||||||
*/
|
*/
|
||||||
if (red < 0 || red > 0xFF ||
|
if (red < 0 || red > 0xFF ||
|
||||||
green < 0 || green > 0xFF ||
|
green < 0 || green > 0xFF ||
|
||||||
blue < 0 || blue > 0xFF) {
|
blue < 0 || blue > 0xFF)
|
||||||
i--;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
/* Allocate memory for ascii name. If error give up here. */
|
/* Allocate memory for ascii name. If error give up here. */
|
||||||
if (!(rgbname = (char *) XpmMalloc(strlen(name) + 1)))
|
if (!(rgbname = (char *) XpmMalloc(strlen(name) + 1)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Copy string to ascii name and lowercase it. */
|
/* Copy string to ascii name and lowercase it. */
|
||||||
for (n = name, m = rgbname; *n; n++)
|
for (s1 = name, s2 = rgbname; *s1; s1++)
|
||||||
*m++ = tolower(*n);
|
*s2++ = tolower(*s1);
|
||||||
*m = '\0';
|
*s2 = '\0';
|
||||||
|
|
||||||
/* Save the rgb values and ascii name in the array. */
|
/* Save the rgb values and ascii name in the array. */
|
||||||
rgb->r = red * 257; /* 65535/255 = 257 */
|
rgb->r = red * 257; /* 65535/255 = 257 */
|
||||||
rgb->g = green * 257;
|
rgb->g = green * 257;
|
||||||
rgb->b = blue * 257;
|
rgb->b = blue * 257;
|
||||||
rgb->name = rgbname;
|
rgb->name = rgbname;
|
||||||
|
rgb++;
|
||||||
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(rgbf);
|
fclose(rgbf);
|
||||||
|
|
||||||
/* Return the number of read rgb names. */
|
/* Return the number of read rgb names. */
|
||||||
return i < 0 ? 0 : i;
|
return n < 0 ? 0 : n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the color name corresponding to the given rgb values
|
* Return the color name corresponding to the given rgb values
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
xpmGetRgbName(xpmRgbName rgbn[], int rgbn_max, int red, int green, int blue)
|
xpmGetRgbName(rgbn, rgbn_max, red, green, blue)
|
||||||
/* xpmRgbName rgbn[]; */ /* rgb mnemonics from rgb text file */
|
xpmRgbName rgbn[]; /* rgb mnemonics from rgb text file */
|
||||||
/* int rgbn_max; */ /* number of rgb mnemonics in table */
|
int rgbn_max; /* number of rgb mnemonics in table */
|
||||||
/* int red, green, blue; */ /* rgb values */
|
int red, green, blue; /* rgb values */
|
||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -151,7 +141,10 @@ xpmGetRgbName(xpmRgbName rgbn[], int rgbn_max, int red, int green, int blue)
|
|||||||
* Free the strings which have been malloc'ed in xpmReadRgbNames
|
* Free the strings which have been malloc'ed in xpmReadRgbNames
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xpmFreeRgbNames(xpmRgbName rgbn[], int rgbn_max)
|
xpmFreeRgbNames(rgbn, rgbn_max)
|
||||||
|
xpmRgbName rgbn[];
|
||||||
|
int rgbn_max;
|
||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
xpmRgbName *rgb;
|
xpmRgbName *rgb;
|
||||||
@@ -166,7 +159,9 @@ xpmFreeRgbNames(xpmRgbName rgbn[], int rgbn_max)
|
|||||||
#include "rgbtab.h" /* hard coded rgb.txt table */
|
#include "rgbtab.h" /* hard coded rgb.txt table */
|
||||||
|
|
||||||
int
|
int
|
||||||
xpmReadRgbNames(char *rgb_fname, xpmRgbName rgbn[])
|
xpmReadRgbNames(rgb_fname, rgbn)
|
||||||
|
char *rgb_fname;
|
||||||
|
xpmRgbName rgbn[];
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* check for consistency???
|
* check for consistency???
|
||||||
@@ -180,11 +175,11 @@ xpmReadRgbNames(char *rgb_fname, xpmRgbName rgbn[])
|
|||||||
* which has something like #0303 for one color
|
* which has something like #0303 for one color
|
||||||
*/
|
*/
|
||||||
char *
|
char *
|
||||||
xpmGetRgbName(xpmRgbName rgbn[], int rgbn_max, int red, int green, int blue)
|
xpmGetRgbName(rgbn, rgbn_max, red, green, blue)
|
||||||
/* xpmRgbName rgbn[]; */ /* rgb mnemonics from rgb text file
|
xpmRgbName rgbn[]; /* rgb mnemonics from rgb text file
|
||||||
* not used */
|
* not used */
|
||||||
/* int rgbn_max; */ /* not used */
|
int rgbn_max; /* not used */
|
||||||
/* int red, green, blue; */ /* rgb values */
|
int red, green, blue; /* rgb values */
|
||||||
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -193,12 +188,10 @@ xpmGetRgbName(xpmRgbName rgbn[], int rgbn_max, int red, int green, int blue)
|
|||||||
i = 0;
|
i = 0;
|
||||||
while (i < numTheRGBRecords) {
|
while (i < numTheRGBRecords) {
|
||||||
rgbVal = theRGBRecords[i].rgb;
|
rgbVal = theRGBRecords[i].rgb;
|
||||||
#if !defined(__VISAGECPP__)
|
|
||||||
if (GetRValue(rgbVal) == red &&
|
if (GetRValue(rgbVal) == red &&
|
||||||
GetGValue(rgbVal) == green &&
|
GetGValue(rgbVal) == green &&
|
||||||
GetBValue(rgbVal) == blue)
|
GetBValue(rgbVal) == blue)
|
||||||
return (theRGBRecords[i].name);
|
return (theRGBRecords[i].name);
|
||||||
#endif
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@@ -206,7 +199,9 @@ xpmGetRgbName(xpmRgbName rgbn[], int rgbn_max, int red, int green, int blue)
|
|||||||
|
|
||||||
/* used in XParseColor in simx.c */
|
/* used in XParseColor in simx.c */
|
||||||
int
|
int
|
||||||
xpmGetRGBfromName(char *inname, int *r, int *g, int *b)
|
xpmGetRGBfromName(inname, r, g, b)
|
||||||
|
char *inname;
|
||||||
|
int *r, *g, *b;
|
||||||
{
|
{
|
||||||
int left, right, middle;
|
int left, right, middle;
|
||||||
int cmp;
|
int cmp;
|
||||||
@@ -214,7 +209,7 @@ xpmGetRGBfromName(char *inname, int *r, int *g, int *b)
|
|||||||
char *name;
|
char *name;
|
||||||
char *grey, *p;
|
char *grey, *p;
|
||||||
|
|
||||||
name = strdup(inname);
|
name = xpmstrdup(inname);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the table in rgbtab.c has no names with spaces, and no grey, but a
|
* the table in rgbtab.c has no names with spaces, and no grey, but a
|
||||||
@@ -246,14 +241,12 @@ xpmGetRGBfromName(char *inname, int *r, int *g, int *b)
|
|||||||
right = numTheRGBRecords - 1;
|
right = numTheRGBRecords - 1;
|
||||||
do {
|
do {
|
||||||
middle = (left + right) / 2;
|
middle = (left + right) / 2;
|
||||||
cmp = strcasecmp(name, theRGBRecords[middle].name);
|
cmp = xpmstrcasecmp(name, theRGBRecords[middle].name);
|
||||||
if (cmp == 0) {
|
if (cmp == 0) {
|
||||||
rgbVal = theRGBRecords[middle].rgb;
|
rgbVal = theRGBRecords[middle].rgb;
|
||||||
#if !defined(__VISAGECPP__)
|
|
||||||
*r = GetRValue(rgbVal);
|
*r = GetRValue(rgbVal);
|
||||||
*g = GetGValue(rgbVal);
|
*g = GetGValue(rgbVal);
|
||||||
*b = GetBValue(rgbVal);
|
*b = GetBValue(rgbVal);
|
||||||
#endif
|
|
||||||
free(name);
|
free(name);
|
||||||
return (1);
|
return (1);
|
||||||
} else if (cmp < 0) {
|
} else if (cmp < 0) {
|
||||||
@@ -278,7 +271,10 @@ xpmGetRGBfromName(char *inname, int *r, int *g, int *b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
xpmFreeRgbNames(xpmRgbName rgbn[], int rgbn_max)
|
xpmFreeRgbNames(rgbn, rgbn_max)
|
||||||
|
xpmRgbName rgbn[];
|
||||||
|
int rgbn_max;
|
||||||
|
|
||||||
{
|
{
|
||||||
/* nothing to do */
|
/* nothing to do */
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -47,13 +47,6 @@ typedef struct {
|
|||||||
#define myRGB(r,g,b) \
|
#define myRGB(r,g,b) \
|
||||||
((unsigned long)r<<16|(unsigned long)g<<8|(unsigned long)b)
|
((unsigned long)r<<16|(unsigned long)g<<8|(unsigned long)b)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Need an RBG conversion confunction here for OS/2 */
|
|
||||||
#if defined(__VISAGECPP__)
|
|
||||||
/* Bogus stuff to make it compile for now */
|
|
||||||
static rgbRecord theRGBRecords[] = { {"AliceBlue", 0L}, {"AntiqueWhite", 1L}, NULL };
|
|
||||||
static int numTheRGBRecords = 2;
|
|
||||||
#else
|
|
||||||
#define myRGB(r,g,b) RGB(r,g,b) /* MSW has this macro */
|
#define myRGB(r,g,b) RGB(r,g,b) /* MSW has this macro */
|
||||||
|
|
||||||
|
|
||||||
@@ -297,4 +290,3 @@ static rgbRecord theRGBRecords[] =
|
|||||||
};
|
};
|
||||||
|
|
||||||
static int numTheRGBRecords = 234;
|
static int numTheRGBRecords = 234;
|
||||||
#endif
|
|
||||||
|
388
src/xpm/scan.c
388
src/xpm/scan.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -37,7 +37,12 @@
|
|||||||
* HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
|
* HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "xpm34p.h"
|
/*
|
||||||
|
* The code related to AMIGA has been added by
|
||||||
|
* Lorens Younes (d93-hyo@nada.kth.se) 4/96
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "XpmI.h"
|
||||||
|
|
||||||
#define MAXPRINTABLE 92 /* number of printable ascii chars
|
#define MAXPRINTABLE 92 /* number of printable ascii chars
|
||||||
* minus \ and " for string compat
|
* minus \ and " for string compat
|
||||||
@@ -69,6 +74,7 @@ LFUNC(storeMaskPixel, int, (Pixel pixel, PixelsMap *pmap,
|
|||||||
unsigned int *index_return));
|
unsigned int *index_return));
|
||||||
|
|
||||||
#ifndef FOR_MSW
|
#ifndef FOR_MSW
|
||||||
|
# ifndef AMIGA
|
||||||
LFUNC(GetImagePixels, int, (XImage *image, unsigned int width,
|
LFUNC(GetImagePixels, int, (XImage *image, unsigned int width,
|
||||||
unsigned int height, PixelsMap *pmap));
|
unsigned int height, PixelsMap *pmap));
|
||||||
|
|
||||||
@@ -83,16 +89,16 @@ LFUNC(GetImagePixels8, int, (XImage *image, unsigned int width,
|
|||||||
|
|
||||||
LFUNC(GetImagePixels1, int, (XImage *image, unsigned int width,
|
LFUNC(GetImagePixels1, int, (XImage *image, unsigned int width,
|
||||||
unsigned int height, PixelsMap *pmap,
|
unsigned int height, PixelsMap *pmap,
|
||||||
int (*storeFunc) (Pixel,PixelsMap*,
|
|
||||||
unsigned int*)));
|
|
||||||
|
|
||||||
/*
|
|
||||||
int (*storeFunc) ()));
|
int (*storeFunc) ()));
|
||||||
*/
|
# else /* AMIGA */
|
||||||
|
LFUNC(AGetImagePixels, int, (XImage *image, unsigned int width,
|
||||||
|
unsigned int height, PixelsMap *pmap,
|
||||||
|
int (*storeFunc) ()));
|
||||||
|
# endif/* AMIGA */
|
||||||
#else /* ndef FOR_MSW */
|
#else /* ndef FOR_MSW */
|
||||||
LFUNC(MSWGetImagePixels, int, (Display *d, XImage *image, unsigned int width,
|
LFUNC(MSWGetImagePixels, int, (Display *d, XImage *image, unsigned int width,
|
||||||
unsigned int height, PixelsMap *pmap));
|
unsigned int height, PixelsMap *pmap,
|
||||||
|
int (*storeFunc) ()));
|
||||||
#endif
|
#endif
|
||||||
LFUNC(ScanTransparentColor, int, (XpmColor *color, unsigned int cpp,
|
LFUNC(ScanTransparentColor, int, (XpmColor *color, unsigned int cpp,
|
||||||
XpmAttributes *attributes));
|
XpmAttributes *attributes));
|
||||||
@@ -106,7 +112,10 @@ LFUNC(ScanOtherColors, int, (Display *display, XpmColor *colors, int ncolors,
|
|||||||
* if not large enough.
|
* if not large enough.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
storePixel(Pixel pixel, PixelsMap *pmap, unsigned int *index_return)
|
storePixel(pixel, pmap, index_return)
|
||||||
|
Pixel pixel;
|
||||||
|
PixelsMap *pmap;
|
||||||
|
unsigned int *index_return;
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
Pixel *p;
|
Pixel *p;
|
||||||
@@ -138,7 +147,10 @@ storePixel(Pixel pixel, PixelsMap *pmap, unsigned int *index_return)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
storeMaskPixel(Pixel pixel, PixelsMap *pmap, unsigned int *index_return)
|
storeMaskPixel(pixel, pmap, index_return)
|
||||||
|
Pixel pixel;
|
||||||
|
PixelsMap *pmap;
|
||||||
|
unsigned int *index_return;
|
||||||
{
|
{
|
||||||
if (!pixel) {
|
if (!pixel) {
|
||||||
if (!pmap->ncolors) {
|
if (!pmap->ncolors) {
|
||||||
@@ -152,14 +164,12 @@ storeMaskPixel(Pixel pixel, PixelsMap *pmap, unsigned int *index_return)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* function call in case of error, frees only locally allocated variables */
|
/* function call in case of error */
|
||||||
#undef RETURN
|
#undef RETURN
|
||||||
#define RETURN(status) \
|
#define RETURN(status) \
|
||||||
{ \
|
{ \
|
||||||
if (pmap.pixelindex) XpmFree(pmap.pixelindex); \
|
ErrorStatus = status; \
|
||||||
if (pmap.pixels) XpmFree(pmap.pixels); \
|
goto error; \
|
||||||
if (colorTable) xpmFreeColorTable(colorTable, pmap.ncolors); \
|
|
||||||
return(status); \
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -167,8 +177,13 @@ storeMaskPixel(Pixel pixel, PixelsMap *pmap, unsigned int *index_return)
|
|||||||
* the given XpmImage structure.
|
* the given XpmImage structure.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
XpmCreateXpmImageFromImage(Display *display, XImage *image, XImage *shapeimage,
|
XpmCreateXpmImageFromImage(display, image, shapeimage,
|
||||||
XpmImage *xpmimage, XpmAttributes *attributes)
|
xpmimage, attributes)
|
||||||
|
Display *display;
|
||||||
|
XImage *image;
|
||||||
|
XImage *shapeimage;
|
||||||
|
XpmImage *xpmimage;
|
||||||
|
XpmAttributes *attributes;
|
||||||
{
|
{
|
||||||
/* variables stored in the XpmAttributes structure */
|
/* variables stored in the XpmAttributes structure */
|
||||||
unsigned int cpp;
|
unsigned int cpp;
|
||||||
@@ -183,7 +198,6 @@ XpmCreateXpmImageFromImage(Display *display, XImage *image, XImage *shapeimage,
|
|||||||
unsigned int height = 0;
|
unsigned int height = 0;
|
||||||
unsigned int cppm; /* minimum chars per pixel */
|
unsigned int cppm; /* minimum chars per pixel */
|
||||||
unsigned int c;
|
unsigned int c;
|
||||||
unsigned int offset;
|
|
||||||
|
|
||||||
/* initialize pmap */
|
/* initialize pmap */
|
||||||
pmap.pixels = NULL;
|
pmap.pixels = NULL;
|
||||||
@@ -228,11 +242,16 @@ XpmCreateXpmImageFromImage(Display *display, XImage *image, XImage *shapeimage,
|
|||||||
*/
|
*/
|
||||||
if (shapeimage) {
|
if (shapeimage) {
|
||||||
#ifndef FOR_MSW
|
#ifndef FOR_MSW
|
||||||
|
# ifndef AMIGA
|
||||||
ErrorStatus = GetImagePixels1(shapeimage, width, height, &pmap,
|
ErrorStatus = GetImagePixels1(shapeimage, width, height, &pmap,
|
||||||
storeMaskPixel);
|
storeMaskPixel);
|
||||||
|
# else
|
||||||
|
ErrorStatus = AGetImagePixels(shapeimage, width, height, &pmap,
|
||||||
|
storeMaskPixel);
|
||||||
|
# endif
|
||||||
#else
|
#else
|
||||||
ErrorStatus = MSWGetImagePixels(display, shapeimage, width, height,
|
ErrorStatus = MSWGetImagePixels(display, shapeimage, width, height,
|
||||||
&pmap);
|
&pmap, storeMaskPixel);
|
||||||
#endif
|
#endif
|
||||||
if (ErrorStatus != XpmSuccess)
|
if (ErrorStatus != XpmSuccess)
|
||||||
RETURN(ErrorStatus);
|
RETURN(ErrorStatus);
|
||||||
@@ -240,27 +259,35 @@ XpmCreateXpmImageFromImage(Display *display, XImage *image, XImage *shapeimage,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* scan the image data
|
* scan the image data
|
||||||
*
|
*
|
||||||
* In case depth is 1 or bits_per_pixel is 4, 6, 8, 24 or 32 use optimized
|
* In case depth is 1 or bits_per_pixel is 4, 6, 8, 24 or 32 use optimized
|
||||||
* functions, otherwise use slower but sure general one.
|
* functions, otherwise use slower but sure general one.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (image) {
|
if (image) {
|
||||||
#ifndef FOR_MSW
|
#ifndef FOR_MSW
|
||||||
if (image->depth == 1)
|
# ifndef AMIGA
|
||||||
|
if (((image->bits_per_pixel | image->depth) == 1) &&
|
||||||
|
(image->byte_order == image->bitmap_bit_order))
|
||||||
ErrorStatus = GetImagePixels1(image, width, height, &pmap,
|
ErrorStatus = GetImagePixels1(image, width, height, &pmap,
|
||||||
storePixel);
|
storePixel);
|
||||||
else if (image->bits_per_pixel == 8)
|
else if (image->format == ZPixmap) {
|
||||||
ErrorStatus = GetImagePixels8(image, width, height, &pmap);
|
if (image->bits_per_pixel == 8)
|
||||||
else if (image->bits_per_pixel == 16)
|
ErrorStatus = GetImagePixels8(image, width, height, &pmap);
|
||||||
ErrorStatus = GetImagePixels16(image, width, height, &pmap);
|
else if (image->bits_per_pixel == 16)
|
||||||
else if (image->bits_per_pixel == 32)
|
ErrorStatus = GetImagePixels16(image, width, height, &pmap);
|
||||||
ErrorStatus = GetImagePixels32(image, width, height, &pmap);
|
else if (image->bits_per_pixel == 32)
|
||||||
else
|
ErrorStatus = GetImagePixels32(image, width, height, &pmap);
|
||||||
|
} else
|
||||||
ErrorStatus = GetImagePixels(image, width, height, &pmap);
|
ErrorStatus = GetImagePixels(image, width, height, &pmap);
|
||||||
#else /* FOR_MSW */
|
# else
|
||||||
ErrorStatus = MSWGetImagePixels(display, image, width, height, &pmap);
|
ErrorStatus = AGetImagePixels(image, width, height, &pmap,
|
||||||
|
storePixel);
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
ErrorStatus = MSWGetImagePixels(display, image, width, height, &pmap,
|
||||||
|
storePixel);
|
||||||
#endif
|
#endif
|
||||||
if (ErrorStatus != XpmSuccess)
|
if (ErrorStatus != XpmSuccess)
|
||||||
RETURN(ErrorStatus);
|
RETURN(ErrorStatus);
|
||||||
@@ -285,13 +312,11 @@ XpmCreateXpmImageFromImage(Display *display, XImage *image, XImage *shapeimage,
|
|||||||
ErrorStatus = ScanTransparentColor(colorTable, cpp, attributes);
|
ErrorStatus = ScanTransparentColor(colorTable, cpp, attributes);
|
||||||
if (ErrorStatus != XpmSuccess)
|
if (ErrorStatus != XpmSuccess)
|
||||||
RETURN(ErrorStatus);
|
RETURN(ErrorStatus);
|
||||||
offset = 1;
|
}
|
||||||
} else
|
|
||||||
offset = 0;
|
|
||||||
|
|
||||||
ErrorStatus = ScanOtherColors(display, colorTable + offset,
|
ErrorStatus = ScanOtherColors(display, colorTable, pmap.ncolors,
|
||||||
pmap.ncolors - offset, pmap.pixels + offset,
|
pmap.pixels, pmap.mask_pixel, cpp,
|
||||||
pmap.mask_pixel, cpp, attributes);
|
attributes);
|
||||||
if (ErrorStatus != XpmSuccess)
|
if (ErrorStatus != XpmSuccess)
|
||||||
RETURN(ErrorStatus);
|
RETURN(ErrorStatus);
|
||||||
|
|
||||||
@@ -307,10 +332,24 @@ XpmCreateXpmImageFromImage(Display *display, XImage *image, XImage *shapeimage,
|
|||||||
|
|
||||||
XpmFree(pmap.pixels);
|
XpmFree(pmap.pixels);
|
||||||
return (XpmSuccess);
|
return (XpmSuccess);
|
||||||
|
|
||||||
|
/* exit point in case of error, free only locally allocated variables */
|
||||||
|
error:
|
||||||
|
if (pmap.pixelindex)
|
||||||
|
XpmFree(pmap.pixelindex);
|
||||||
|
if (pmap.pixels)
|
||||||
|
XpmFree(pmap.pixels);
|
||||||
|
if (colorTable)
|
||||||
|
xpmFreeColorTable(colorTable, pmap.ncolors);
|
||||||
|
|
||||||
|
return (ErrorStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ScanTransparentColor(XpmColor *color, unsigned int cpp, XpmAttributes *attributes)
|
ScanTransparentColor(color, cpp, attributes)
|
||||||
|
XpmColor *color;
|
||||||
|
unsigned int cpp;
|
||||||
|
XpmAttributes *attributes;
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
unsigned int a, b, c;
|
unsigned int a, b, c;
|
||||||
@@ -325,33 +364,35 @@ ScanTransparentColor(XpmColor *color, unsigned int cpp, XpmAttributes *attribute
|
|||||||
*s = '\0';
|
*s = '\0';
|
||||||
|
|
||||||
/* then retreive related info from the attributes if any */
|
/* then retreive related info from the attributes if any */
|
||||||
if (attributes && attributes->mask_pixel != XpmUndefPixel && (
|
if (attributes && (attributes->valuemask & XpmColorTable
|
||||||
/* 3.2 backward compatibility code */
|
/* 3.2 backward compatibility code */
|
||||||
attributes->valuemask & XpmInfos ||
|
|| attributes->valuemask & XpmInfos)
|
||||||
/* end 3.2 bc */
|
/* end 3.2 bc */
|
||||||
attributes->valuemask & XpmColorTable)) {
|
&& attributes->mask_pixel != XpmUndefPixel) {
|
||||||
|
|
||||||
unsigned int key;
|
unsigned int key;
|
||||||
char **defaults = (char **) color;
|
char **defaults = (char **) color;
|
||||||
char **mask_defaults;
|
char **mask_defaults;
|
||||||
|
|
||||||
/* 3.2 backward compatibility code */
|
/* 3.2 backward compatibility code */
|
||||||
if (attributes->valuemask & XpmInfos)
|
if (attributes->valuemask & XpmColorTable)
|
||||||
mask_defaults = (char **)
|
|
||||||
((XpmColor **) attributes->colorTable)[attributes->mask_pixel];
|
|
||||||
else
|
|
||||||
/* end 3.2 bc */
|
/* end 3.2 bc */
|
||||||
mask_defaults = (char **) (
|
mask_defaults = (char **) (
|
||||||
attributes->colorTable + attributes->mask_pixel);
|
attributes->colorTable + attributes->mask_pixel);
|
||||||
|
/* 3.2 backward compatibility code */
|
||||||
|
else
|
||||||
|
mask_defaults = (char **)
|
||||||
|
((XpmColor **) attributes->colorTable)[attributes->mask_pixel];
|
||||||
|
/* end 3.2 bc */
|
||||||
for (key = 1; key <= NKEYS; key++) {
|
for (key = 1; key <= NKEYS; key++) {
|
||||||
if (s = mask_defaults[key]) {
|
if (s = mask_defaults[key]) {
|
||||||
defaults[key] = (char *) strdup(s);
|
defaults[key] = (char *) xpmstrdup(s);
|
||||||
if (!defaults[key])
|
if (!defaults[key])
|
||||||
return (XpmNoMemory);
|
return (XpmNoMemory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
color->c_color = (char *) strdup(TRANSPARENT_COLOR);
|
color->c_color = (char *) xpmstrdup(TRANSPARENT_COLOR);
|
||||||
if (!color->c_color)
|
if (!color->c_color)
|
||||||
return (XpmNoMemory);
|
return (XpmNoMemory);
|
||||||
}
|
}
|
||||||
@@ -359,8 +400,14 @@ ScanTransparentColor(XpmColor *color, unsigned int cpp, XpmAttributes *attribute
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels,
|
ScanOtherColors(display, colors, ncolors, pixels, mask, cpp, attributes)
|
||||||
unsigned int mask, unsigned int cpp, XpmAttributes *attributes)
|
Display *display;
|
||||||
|
XpmColor *colors;
|
||||||
|
int ncolors;
|
||||||
|
Pixel *pixels;
|
||||||
|
unsigned int mask;
|
||||||
|
unsigned int cpp;
|
||||||
|
XpmAttributes *attributes;
|
||||||
{
|
{
|
||||||
/* variables stored in the XpmAttributes structure */
|
/* variables stored in the XpmAttributes structure */
|
||||||
Colormap colormap;
|
Colormap colormap;
|
||||||
@@ -369,8 +416,8 @@ ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels,
|
|||||||
#ifndef FOR_MSW
|
#ifndef FOR_MSW
|
||||||
xpmRgbName rgbn[MAX_RGBNAMES];
|
xpmRgbName rgbn[MAX_RGBNAMES];
|
||||||
#else
|
#else
|
||||||
xpmRgbName *rgbn = NULL;
|
xpmRgbName *rgbn = NULL;
|
||||||
#endif
|
#endif
|
||||||
int rgbn_max = 0;
|
int rgbn_max = 0;
|
||||||
unsigned int i, j, c, i2;
|
unsigned int i, j, c, i2;
|
||||||
XpmColor *color;
|
XpmColor *color;
|
||||||
@@ -380,7 +427,7 @@ ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels,
|
|||||||
unsigned int ancolors = 0;
|
unsigned int ancolors = 0;
|
||||||
Pixel *apixels;
|
Pixel *apixels;
|
||||||
unsigned int mask_pixel;
|
unsigned int mask_pixel;
|
||||||
int found;
|
Bool found;
|
||||||
|
|
||||||
/* retrieve information from the XpmAttributes */
|
/* retrieve information from the XpmAttributes */
|
||||||
if (attributes && (attributes->valuemask & XpmColormap))
|
if (attributes && (attributes->valuemask & XpmColormap))
|
||||||
@@ -392,13 +439,20 @@ ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels,
|
|||||||
else
|
else
|
||||||
rgb_fname = NULL;
|
rgb_fname = NULL;
|
||||||
|
|
||||||
|
/* start from the right element */
|
||||||
|
if (mask) {
|
||||||
|
colors++;
|
||||||
|
ncolors--;
|
||||||
|
pixels++;
|
||||||
|
}
|
||||||
|
|
||||||
/* first get character strings and rgb values */
|
/* first get character strings and rgb values */
|
||||||
xcolors = (XColor *) XpmMalloc(sizeof(XColor) * ncolors);
|
xcolors = (XColor *) XpmMalloc(sizeof(XColor) * ncolors);
|
||||||
if (!xcolors)
|
if (!xcolors)
|
||||||
return (XpmNoMemory);
|
return (XpmNoMemory);
|
||||||
|
|
||||||
for (i = 0, i2 = (mask ? i + 1 : i), color = colors, xcolor = xcolors;
|
for (i = 0, i2 = mask, color = colors, xcolor = xcolors;
|
||||||
i < (unsigned int)ncolors; i++, i2++, color++, xcolor++, pixels++) {
|
i < ncolors; i++, i2++, color++, xcolor++, pixels++) {
|
||||||
|
|
||||||
if (!(s = color->string = (char *) XpmMalloc(cpp + 1))) {
|
if (!(s = color->string = (char *) XpmMalloc(cpp + 1))) {
|
||||||
XpmFree(xcolors);
|
XpmFree(xcolors);
|
||||||
@@ -411,11 +465,7 @@ ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels,
|
|||||||
|
|
||||||
xcolor->pixel = *pixels;
|
xcolor->pixel = *pixels;
|
||||||
}
|
}
|
||||||
#if defined(wx_msw) || defined(wx_pm)
|
XQueryColors(display, colormap, xcolors, ncolors);
|
||||||
XQueryColors(display, (Colormap *)colormap, xcolors, ncolors);
|
|
||||||
#else
|
|
||||||
XQueryColors(display, (Colormap)colormap, xcolors, ncolors);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef FOR_MSW
|
#ifndef FOR_MSW
|
||||||
/* read the rgb file if any was specified */
|
/* read the rgb file if any was specified */
|
||||||
@@ -441,7 +491,7 @@ ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels,
|
|||||||
}
|
}
|
||||||
/* end 3.2 bc */
|
/* end 3.2 bc */
|
||||||
|
|
||||||
for (i = 0, color = colors, xcolor = xcolors; i < (unsigned int)ncolors;
|
for (i = 0, color = colors, xcolor = xcolors; i < ncolors;
|
||||||
i++, color++, xcolor++) {
|
i++, color++, xcolor++) {
|
||||||
|
|
||||||
/* look for related info from the attributes if any */
|
/* look for related info from the attributes if any */
|
||||||
@@ -472,7 +522,7 @@ ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels,
|
|||||||
found = True;
|
found = True;
|
||||||
for (key = 1; key <= NKEYS; key++) {
|
for (key = 1; key <= NKEYS; key++) {
|
||||||
if (s = adefaults[key])
|
if (s = adefaults[key])
|
||||||
defaults[key] = (char *) strdup(s);
|
defaults[key] = (char *) xpmstrdup(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -483,18 +533,18 @@ ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels,
|
|||||||
colorname = xpmGetRgbName(rgbn, rgbn_max, xcolor->red,
|
colorname = xpmGetRgbName(rgbn, rgbn_max, xcolor->red,
|
||||||
xcolor->green, xcolor->blue);
|
xcolor->green, xcolor->blue);
|
||||||
if (colorname)
|
if (colorname)
|
||||||
color->c_color = (char *) strdup(colorname);
|
color->c_color = (char *) xpmstrdup(colorname);
|
||||||
else {
|
else {
|
||||||
/* at last store the rgb value */
|
/* at last store the rgb value */
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
#ifndef FOR_MSW
|
#ifndef FOR_MSW
|
||||||
sprintf(buf, "#%04X%04X%04X",
|
sprintf(buf, "#%04X%04X%04X",
|
||||||
xcolor->red, xcolor->green, xcolor->blue);
|
xcolor->red, xcolor->green, xcolor->blue);
|
||||||
#else
|
#else
|
||||||
sprintf(buf, "#%02x%02x%02x",
|
sprintf(buf, "#%02x%02x%02x",
|
||||||
xcolor->red, xcolor->green, xcolor->blue);
|
xcolor->red, xcolor->green, xcolor->blue);
|
||||||
#endif
|
#endif
|
||||||
color->c_color = (char *) strdup(buf);
|
color->c_color = (char *) xpmstrdup(buf);
|
||||||
}
|
}
|
||||||
if (!color->c_color) {
|
if (!color->c_color) {
|
||||||
XpmFree(xcolors);
|
XpmFree(xcolors);
|
||||||
@@ -510,13 +560,14 @@ ScanOtherColors(Display *display, XpmColor *colors, int ncolors, Pixel *pixels,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef FOR_MSW
|
#ifndef FOR_MSW
|
||||||
|
# ifndef AMIGA
|
||||||
/*
|
/*
|
||||||
* The functions below are written from X11R5 MIT's code (XImUtil.c)
|
* The functions below are written from X11R5 MIT's code (XImUtil.c)
|
||||||
*
|
*
|
||||||
* The idea is to have faster functions than the standard XGetPixel function
|
* The idea is to have faster functions than the standard XGetPixel function
|
||||||
* to scan the image data. Indeed we can speed up things by suppressing tests
|
* to scan the image data. Indeed we can speed up things by suppressing tests
|
||||||
* performed for each pixel. We do exactly the same tests but at the image
|
* performed for each pixel. We do exactly the same tests but at the image
|
||||||
* level. Assuming that we use only ZPixmap images.
|
* level.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static unsigned long Const low_bits_table[] = {
|
static unsigned long Const low_bits_table[] = {
|
||||||
@@ -532,7 +583,7 @@ static unsigned long Const low_bits_table[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Default method to scan pixels of a Z image data structure.
|
* Default method to scan pixels of an image data structure.
|
||||||
* The algorithm used is:
|
* The algorithm used is:
|
||||||
*
|
*
|
||||||
* copy the source bitmap_unit or Zpixel into temp
|
* copy the source bitmap_unit or Zpixel into temp
|
||||||
@@ -542,14 +593,18 @@ static unsigned long Const low_bits_table[] = {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
GetImagePixels(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap)
|
GetImagePixels(image, width, height, pmap)
|
||||||
|
XImage *image;
|
||||||
|
unsigned int width;
|
||||||
|
unsigned int height;
|
||||||
|
PixelsMap *pmap;
|
||||||
{
|
{
|
||||||
char *src;
|
char *src;
|
||||||
char *dst;
|
char *dst;
|
||||||
unsigned int *iptr;
|
unsigned int *iptr;
|
||||||
char *data;
|
char *data;
|
||||||
int x, y, i;
|
int x, y, i;
|
||||||
int bits, depth, ibu, ibpp;
|
int bits, depth, ibu, ibpp, offset;
|
||||||
unsigned long lbt;
|
unsigned long lbt;
|
||||||
Pixel pixel, px;
|
Pixel pixel, px;
|
||||||
|
|
||||||
@@ -558,7 +613,9 @@ GetImagePixels(XImage *image, unsigned int width, unsigned int height, PixelsMap
|
|||||||
depth = image->depth;
|
depth = image->depth;
|
||||||
lbt = low_bits_table[depth];
|
lbt = low_bits_table[depth];
|
||||||
ibpp = image->bits_per_pixel;
|
ibpp = image->bits_per_pixel;
|
||||||
if (image->depth == 1) {
|
offset = image->xoffset;
|
||||||
|
|
||||||
|
if ((image->bits_per_pixel | image->depth) == 1) {
|
||||||
ibu = image->bitmap_unit;
|
ibu = image->bitmap_unit;
|
||||||
for (y = 0; y < height; y++)
|
for (y = 0; y < height; y++)
|
||||||
for (x = 0; x < width; x++, iptr++) {
|
for (x = 0; x < width; x++, iptr++) {
|
||||||
@@ -568,14 +625,41 @@ GetImagePixels(XImage *image, unsigned int width, unsigned int height, PixelsMap
|
|||||||
for (i = ibu >> 3; --i >= 0;)
|
for (i = ibu >> 3; --i >= 0;)
|
||||||
*dst++ = *src++;
|
*dst++ = *src++;
|
||||||
XYNORMALIZE(&pixel, image);
|
XYNORMALIZE(&pixel, image);
|
||||||
bits = x % ibu;
|
bits = (x + offset) % ibu;
|
||||||
pixel = ((((char *) &pixel)[bits >> 3]) >> (bits & 7)) & 1;
|
pixel = ((((char *) &pixel)[bits >> 3]) >> (bits & 7)) & 1;
|
||||||
if (ibpp != depth)
|
if (ibpp != depth)
|
||||||
pixel &= lbt;
|
pixel &= lbt;
|
||||||
if (storePixel(pixel, pmap, iptr))
|
if (storePixel(pixel, pmap, iptr))
|
||||||
return (XpmNoMemory);
|
return (XpmNoMemory);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (image->format == XYPixmap) {
|
||||||
|
int nbytes, bpl, j;
|
||||||
|
long plane = 0;
|
||||||
|
ibu = image->bitmap_unit;
|
||||||
|
nbytes = ibu >> 3;
|
||||||
|
bpl = image->bytes_per_line;
|
||||||
|
for (y = 0; y < height; y++)
|
||||||
|
for (x = 0; x < width; x++, iptr++) {
|
||||||
|
pixel = 0;
|
||||||
|
plane = 0;
|
||||||
|
for (i = depth; --i >= 0;) {
|
||||||
|
src = &data[XYINDEX(x, y, image) + plane];
|
||||||
|
dst = (char *) &px;
|
||||||
|
px = 0;
|
||||||
|
for (j = nbytes; --j >= 0;)
|
||||||
|
*dst++ = *src++;
|
||||||
|
XYNORMALIZE(&px, image);
|
||||||
|
bits = (x + offset) % ibu;
|
||||||
|
pixel = (pixel << 1) |
|
||||||
|
(((((char *) &px)[bits >> 3]) >> (bits & 7)) & 1);
|
||||||
|
plane = plane + (bpl * height);
|
||||||
|
}
|
||||||
|
if (ibpp != depth)
|
||||||
|
pixel &= lbt;
|
||||||
|
if (storePixel(pixel, pmap, iptr))
|
||||||
|
return (XpmNoMemory);
|
||||||
|
}
|
||||||
|
} else if (image->format == ZPixmap) {
|
||||||
for (y = 0; y < height; y++)
|
for (y = 0; y < height; y++)
|
||||||
for (x = 0; x < width; x++, iptr++) {
|
for (x = 0; x < width; x++, iptr++) {
|
||||||
src = &data[ZINDEX(x, y, image)];
|
src = &data[ZINDEX(x, y, image)];
|
||||||
@@ -598,7 +682,8 @@ GetImagePixels(XImage *image, unsigned int width, unsigned int height, PixelsMap
|
|||||||
if (storePixel(pixel, pmap, iptr))
|
if (storePixel(pixel, pmap, iptr))
|
||||||
return (XpmNoMemory);
|
return (XpmNoMemory);
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
return (XpmColorError); /* actually a bad image */
|
||||||
return (XpmSuccess);
|
return (XpmSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -606,13 +691,16 @@ GetImagePixels(XImage *image, unsigned int width, unsigned int height, PixelsMap
|
|||||||
* scan pixels of a 32-bits Z image data structure
|
* scan pixels of a 32-bits Z image data structure
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef WORD64
|
#if !defined(WORD64) && !defined(LONG64)
|
||||||
static unsigned long byteorderpixel = MSBFirst << 24;
|
static unsigned long byteorderpixel = MSBFirst << 24;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
GetImagePixels32(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap)
|
GetImagePixels32(image, width, height, pmap)
|
||||||
|
XImage *image;
|
||||||
|
unsigned int width;
|
||||||
|
unsigned int height;
|
||||||
|
PixelsMap *pmap;
|
||||||
{
|
{
|
||||||
unsigned char *addr;
|
unsigned char *addr;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
@@ -626,7 +714,7 @@ GetImagePixels32(XImage *image, unsigned int width, unsigned int height, PixelsM
|
|||||||
iptr = pmap->pixelindex;
|
iptr = pmap->pixelindex;
|
||||||
depth = image->depth;
|
depth = image->depth;
|
||||||
lbt = low_bits_table[depth];
|
lbt = low_bits_table[depth];
|
||||||
#ifndef WORD64
|
#if !defined(WORD64) && !defined(LONG64)
|
||||||
if (*((char *) &byteorderpixel) == image->byte_order) {
|
if (*((char *) &byteorderpixel) == image->byte_order) {
|
||||||
for (y = 0; y < height; y++)
|
for (y = 0; y < height; y++)
|
||||||
for (x = 0; x < width; x++, iptr++) {
|
for (x = 0; x < width; x++, iptr++) {
|
||||||
@@ -646,7 +734,7 @@ GetImagePixels32(XImage *image, unsigned int width, unsigned int height, PixelsM
|
|||||||
pixel = ((unsigned long) addr[0] << 24 |
|
pixel = ((unsigned long) addr[0] << 24 |
|
||||||
(unsigned long) addr[1] << 16 |
|
(unsigned long) addr[1] << 16 |
|
||||||
(unsigned long) addr[2] << 8 |
|
(unsigned long) addr[2] << 8 |
|
||||||
addr[4]);
|
addr[3]);
|
||||||
if (depth != 32)
|
if (depth != 32)
|
||||||
pixel &= lbt;
|
pixel &= lbt;
|
||||||
if (storePixel(pixel, pmap, iptr))
|
if (storePixel(pixel, pmap, iptr))
|
||||||
@@ -673,7 +761,11 @@ GetImagePixels32(XImage *image, unsigned int width, unsigned int height, PixelsM
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
GetImagePixels16(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap)
|
GetImagePixels16(image, width, height, pmap)
|
||||||
|
XImage *image;
|
||||||
|
unsigned int width;
|
||||||
|
unsigned int height;
|
||||||
|
PixelsMap *pmap;
|
||||||
{
|
{
|
||||||
unsigned char *addr;
|
unsigned char *addr;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
@@ -715,7 +807,11 @@ GetImagePixels16(XImage *image, unsigned int width, unsigned int height, PixelsM
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
GetImagePixels8(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap)
|
GetImagePixels8(image, width, height, pmap)
|
||||||
|
XImage *image;
|
||||||
|
unsigned int width;
|
||||||
|
unsigned int height;
|
||||||
|
PixelsMap *pmap;
|
||||||
{
|
{
|
||||||
unsigned int *iptr;
|
unsigned int *iptr;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
@@ -744,46 +840,103 @@ GetImagePixels8(XImage *image, unsigned int width, unsigned int height, PixelsMa
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
GetImagePixels1(XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap,
|
GetImagePixels1(image, width, height, pmap, storeFunc)
|
||||||
/*
|
XImage *image;
|
||||||
int (*storeFunc)()
|
unsigned int width;
|
||||||
*/
|
unsigned int height;
|
||||||
int (*storeFunc)(Pixel,PixelsMap*,unsigned int*)
|
PixelsMap *pmap;
|
||||||
)
|
int (*storeFunc) ();
|
||||||
{
|
{
|
||||||
unsigned int *iptr;
|
unsigned int *iptr;
|
||||||
int x, y;
|
int x, y;
|
||||||
char *data;
|
char *data;
|
||||||
Pixel pixel;
|
Pixel pixel;
|
||||||
|
int xoff, yoff, offset, bpl;
|
||||||
|
|
||||||
if (image->byte_order != image->bitmap_bit_order)
|
data = image->data;
|
||||||
return (GetImagePixels(image, width, height, pmap));
|
iptr = pmap->pixelindex;
|
||||||
else {
|
offset = image->xoffset;
|
||||||
data = image->data;
|
bpl = image->bytes_per_line;
|
||||||
iptr = pmap->pixelindex;
|
|
||||||
if (image->bitmap_bit_order == MSBFirst)
|
if (image->bitmap_bit_order == MSBFirst)
|
||||||
for (y = 0; y < height; y++)
|
for (y = 0; y < height; y++)
|
||||||
for (x = 0; x < width; x++, iptr++) {
|
for (x = 0; x < width; x++, iptr++) {
|
||||||
pixel = (data[ZINDEX1(x, y, image)] & (0x80 >> (x & 7)))
|
xoff = x + offset;
|
||||||
? 1 : 0;
|
yoff = y * bpl + (xoff >> 3);
|
||||||
if ((*storeFunc) (pixel, pmap, iptr))
|
xoff &= 7;
|
||||||
return (XpmNoMemory);
|
pixel = (data[yoff] & (0x80 >> xoff)) ? 1 : 0;
|
||||||
}
|
if ((*storeFunc) (pixel, pmap, iptr))
|
||||||
else
|
return (XpmNoMemory);
|
||||||
for (y = 0; y < height; y++)
|
}
|
||||||
for (x = 0; x < width; x++, iptr++) {
|
else
|
||||||
pixel = (data[ZINDEX1(x, y, image)] & (1 << (x & 7)))
|
for (y = 0; y < height; y++)
|
||||||
? 1 : 0;
|
for (x = 0; x < width; x++, iptr++) {
|
||||||
if ((*storeFunc) (pixel, pmap, iptr))
|
xoff = x + offset;
|
||||||
return (XpmNoMemory);
|
yoff = y * bpl + (xoff >> 3);
|
||||||
}
|
xoff &= 7;
|
||||||
}
|
pixel = (data[yoff] & (1 << xoff)) ? 1 : 0;
|
||||||
|
if ((*storeFunc) (pixel, pmap, iptr))
|
||||||
|
return (XpmNoMemory);
|
||||||
|
}
|
||||||
return (XpmSuccess);
|
return (XpmSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# else /* AMIGA */
|
||||||
|
|
||||||
|
#define CLEAN_UP(status) \
|
||||||
|
{\
|
||||||
|
if (pixels) XpmFree (pixels);\
|
||||||
|
if (tmp_img) FreeXImage (tmp_img);\
|
||||||
|
return (status);\
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
AGetImagePixels (
|
||||||
|
XImage *image,
|
||||||
|
unsigned int width,
|
||||||
|
unsigned int height,
|
||||||
|
PixelsMap *pmap,
|
||||||
|
int (*storeFunc) ())
|
||||||
|
{
|
||||||
|
unsigned int *iptr;
|
||||||
|
unsigned int x, y;
|
||||||
|
unsigned char *pixels;
|
||||||
|
XImage *tmp_img;
|
||||||
|
|
||||||
|
pixels = XpmMalloc ((((width+15)>>4)<<4)*sizeof (*pixels));
|
||||||
|
if (pixels == NULL)
|
||||||
|
return XpmNoMemory;
|
||||||
|
|
||||||
|
tmp_img = AllocXImage ((((width+15)>>4)<<4), 1, image->rp->BitMap->Depth);
|
||||||
|
if (tmp_img == NULL)
|
||||||
|
CLEAN_UP (XpmNoMemory)
|
||||||
|
|
||||||
|
iptr = pmap->pixelindex;
|
||||||
|
for (y = 0; y < height; ++y)
|
||||||
|
{
|
||||||
|
ReadPixelLine8 (image->rp, 0, y, width, pixels, tmp_img->rp);
|
||||||
|
for (x = 0; x < width; ++x, ++iptr)
|
||||||
|
{
|
||||||
|
if ((*storeFunc) (pixels[x], pmap, iptr))
|
||||||
|
CLEAN_UP (XpmNoMemory)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CLEAN_UP (XpmSuccess)
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef CLEAN_UP
|
||||||
|
|
||||||
|
# endif/* AMIGA */
|
||||||
#else /* ndef FOR_MSW */
|
#else /* ndef FOR_MSW */
|
||||||
static int
|
static int
|
||||||
MSWGetImagePixels(Display *display, XImage *image, unsigned int width, unsigned int height, PixelsMap *pmap)
|
MSWGetImagePixels(display, image, width, height, pmap, storeFunc)
|
||||||
|
Display *display;
|
||||||
|
XImage *image;
|
||||||
|
unsigned int width;
|
||||||
|
unsigned int height;
|
||||||
|
PixelsMap *pmap;
|
||||||
|
int (*storeFunc) ();
|
||||||
{
|
{
|
||||||
unsigned int *iptr;
|
unsigned int *iptr;
|
||||||
unsigned int x, y;
|
unsigned int x, y;
|
||||||
@@ -791,15 +944,13 @@ MSWGetImagePixels(Display *display, XImage *image, unsigned int width, unsigned
|
|||||||
|
|
||||||
iptr = pmap->pixelindex;
|
iptr = pmap->pixelindex;
|
||||||
|
|
||||||
|
SelectObject(*display, image->bitmap);
|
||||||
for (y = 0; y < height; y++) {
|
for (y = 0; y < height; y++) {
|
||||||
#if !defined(__VISAGECPP__) /* fixme for OS/2 */
|
|
||||||
for (x = 0; x < width; x++, iptr++) {
|
for (x = 0; x < width; x++, iptr++) {
|
||||||
/* bitmap must be selected !!! ??? */
|
|
||||||
pixel = GetPixel(*display, x, y);
|
pixel = GetPixel(*display, x, y);
|
||||||
if (storePixel(pixel, pmap, iptr))
|
if ((*storeFunc) (pixel, pmap, iptr))
|
||||||
return (XpmNoMemory);
|
return (XpmNoMemory);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return (XpmSuccess);
|
return (XpmSuccess);
|
||||||
}
|
}
|
||||||
@@ -807,9 +958,15 @@ MSWGetImagePixels(Display *display, XImage *image, unsigned int width, unsigned
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FOR_MSW
|
#ifndef FOR_MSW
|
||||||
|
# ifndef AMIGA
|
||||||
int
|
int
|
||||||
XpmCreateXpmImageFromPixmap(Display *display, Pixmap pixmap, Pixmap shapemask,
|
XpmCreateXpmImageFromPixmap(display, pixmap, shapemask,
|
||||||
XpmImage *xpmimage, XpmAttributes *attributes)
|
xpmimage, attributes)
|
||||||
|
Display *display;
|
||||||
|
Pixmap pixmap;
|
||||||
|
Pixmap shapemask;
|
||||||
|
XpmImage *xpmimage;
|
||||||
|
XpmAttributes *attributes;
|
||||||
{
|
{
|
||||||
XImage *ximage = NULL;
|
XImage *ximage = NULL;
|
||||||
XImage *shapeimage = NULL;
|
XImage *shapeimage = NULL;
|
||||||
@@ -842,4 +999,5 @@ XpmCreateXpmImageFromPixmap(Display *display, Pixmap pixmap, Pixmap shapemask,
|
|||||||
return (ErrorStatus);
|
return (ErrorStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# endif/* not AMIGA */
|
||||||
#endif /* ndef FOR_MSW */
|
#endif /* ndef FOR_MSW */
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -33,11 +33,12 @@
|
|||||||
* Developed by HeDu 3/94 (hedu@cul-ipn.uni-kiel.de) *
|
* Developed by HeDu 3/94 (hedu@cul-ipn.uni-kiel.de) *
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
#include "xpm34.h"
|
/* Moved here so that FOR_MSW gets defined if we are using wxWindows (GRG) */
|
||||||
|
#include "xpm.h"
|
||||||
|
|
||||||
#ifdef FOR_MSW
|
#ifdef FOR_MSW
|
||||||
|
|
||||||
#include "xpm34p.h" /* for XpmMalloc */
|
#include "xpmi.h" /* for XpmMalloc */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* On DOS size_t is only 2 bytes, thus malloc(size_t s) can only malloc
|
* On DOS size_t is only 2 bytes, thus malloc(size_t s) can only malloc
|
||||||
@@ -119,21 +120,14 @@ XDefaultScreen(Display *d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* I get only 1 plane but 8 bits per pixel,
|
/* I get only 1 plane but 8 bits per pixel,
|
||||||
so I think BITSPIXEL should be depth
|
so I think BITSPIXEL should be depth */
|
||||||
|
int
|
||||||
TRS: I assume that all "displays" have the same number of
|
|
||||||
planes later in the code, which is based on the assumption
|
|
||||||
that the display variable is ignored below. :)
|
|
||||||
*/
|
|
||||||
int
|
|
||||||
XDefaultDepth(Display *display, Screen *screen)
|
XDefaultDepth(Display *display, Screen *screen)
|
||||||
{
|
{
|
||||||
int d, b;
|
int d, b;
|
||||||
|
|
||||||
#if !defined(__VISAGECPP__) /* fisme for OS/2 */
|
|
||||||
b = GetDeviceCaps(*display, BITSPIXEL);
|
b = GetDeviceCaps(*display, BITSPIXEL);
|
||||||
d = GetDeviceCaps(*display, PLANES);
|
d = GetDeviceCaps(*display, PLANES);
|
||||||
#endif
|
|
||||||
return (b);
|
return (b);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,8 +139,8 @@ XDefaultColormap(Display *display, Screen *screen)
|
|||||||
|
|
||||||
/* convert hex color names,
|
/* convert hex color names,
|
||||||
wrong digits (not a-f,A-F,0-9) are treated as zero */
|
wrong digits (not a-f,A-F,0-9) are treated as zero */
|
||||||
static int
|
static int
|
||||||
hexCharToInt(char c)
|
hexCharToInt(c)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@@ -162,7 +156,7 @@ hexCharToInt(char c)
|
|||||||
return (r);
|
return (r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
rgbFromHex(char *hex, int *r, int *g, int *b)
|
rgbFromHex(char *hex, int *r, int *g, int *b)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
@@ -192,7 +186,7 @@ rgbFromHex(char *hex, int *r, int *g, int *b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Color related functions */
|
/* Color related functions */
|
||||||
int
|
int
|
||||||
XParseColor(Display *d, Colormap *cmap, char *name, XColor *color)
|
XParseColor(Display *d, Colormap *cmap, char *name, XColor *color)
|
||||||
{
|
{
|
||||||
int r, g, b; /* only 8 bit values used */
|
int r, g, b; /* only 8 bit values used */
|
||||||
@@ -210,9 +204,7 @@ XParseColor(Display *d, Colormap *cmap, char *name, XColor *color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (okay) {
|
if (okay) {
|
||||||
#if !defined(__VISAGECPP__) /* fixme for OS/2 */
|
|
||||||
color->pixel = RGB(r, g, b);
|
color->pixel = RGB(r, g, b);
|
||||||
#endif
|
|
||||||
color->red = (BYTE) r;
|
color->red = (BYTE) r;
|
||||||
color->green = (BYTE) g;
|
color->green = (BYTE) g;
|
||||||
color->blue = (BYTE) b;
|
color->blue = (BYTE) b;
|
||||||
@@ -222,14 +214,16 @@ XParseColor(Display *d, Colormap *cmap, char *name, XColor *color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
/* GRG: 2nd arg is Colormap*, not Colormap */
|
||||||
|
|
||||||
|
int
|
||||||
XAllocColor(Display *d, Colormap *cmap, XColor *color)
|
XAllocColor(Display *d, Colormap *cmap, XColor *color)
|
||||||
{
|
{
|
||||||
/* colormap not used yet so color->pixel is the real COLORREF (RBG) and not an
|
/* colormap not used yet so color->pixel is the real COLORREF (RBG) and not an
|
||||||
index in some colormap as in X */
|
index in some colormap as in X */
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
XQueryColors(Display *display, Colormap *colormap,
|
XQueryColors(Display *display, Colormap *colormap,
|
||||||
XColor *xcolors, int ncolors)
|
XColor *xcolors, int ncolors)
|
||||||
{
|
{
|
||||||
@@ -238,16 +232,14 @@ XQueryColors(Display *display, Colormap *colormap,
|
|||||||
XColor *xc = xcolors;
|
XColor *xc = xcolors;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#if !defined(__VISAGECPP__) /* fixme for OS/2 */
|
|
||||||
for (i = 0; i < ncolors; i++, xc++) {
|
for (i = 0; i < ncolors; i++, xc++) {
|
||||||
xc->red = GetRValue(xc->pixel);
|
xc->red = GetRValue(xc->pixel);
|
||||||
xc->green = GetGValue(xc->pixel);
|
xc->green = GetGValue(xc->pixel);
|
||||||
xc->blue = GetBValue(xc->pixel);
|
xc->blue = GetBValue(xc->pixel);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int
|
int
|
||||||
XFreeColors(Display *d, Colormap cmap,
|
XFreeColors(Display *d, Colormap cmap,
|
||||||
unsigned long pixels[], int npixels, unsigned long planes)
|
unsigned long pixels[], int npixels, unsigned long planes)
|
||||||
{
|
{
|
||||||
@@ -265,15 +257,16 @@ XCreateImage(Display *d, Visual *v,
|
|||||||
XImage *img = (XImage *) XpmMalloc(sizeof(XImage));
|
XImage *img = (XImage *) XpmMalloc(sizeof(XImage));
|
||||||
|
|
||||||
if (img) {
|
if (img) {
|
||||||
/* *img = CreateCompatibleBitmap(*d, width, height); */
|
/*JW: This is what it should be, but the picture comes out
|
||||||
|
just black!? It appears to be doing monochrome reduction,
|
||||||
#if !defined(__VISAGECPP__) /* fixme for OS/2 */
|
but I've got no clue why. Using CreateBitmap() is supposed
|
||||||
/* create the bitmap with the same number of planes as the default display
|
to be slower, but otherwise ok
|
||||||
* (otherwise it wouldn't work for 16 color mode) */
|
if ( depth == GetDeviceCaps(*d, BITSPIXEL) ) {
|
||||||
img->bitmap = CreateBitmap(width, height,
|
img->bitmap = CreateCompatibleBitmap(*d, width, height);
|
||||||
GetDeviceCaps(*d, PLANES),
|
} else*/ {
|
||||||
depth /* bits per pixel */ , NULL);
|
img->bitmap = CreateBitmap(width, height, 1 /* plane */ ,
|
||||||
#endif
|
depth /* bits per pixel */ , NULL);
|
||||||
|
}
|
||||||
img->width = width;
|
img->width = width;
|
||||||
img->height = height;
|
img->height = height;
|
||||||
img->depth = depth;
|
img->depth = depth;
|
||||||
@@ -282,20 +275,18 @@ XCreateImage(Display *d, Visual *v,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XImageFree(XImage *img)
|
XImageFree(XImage *img)
|
||||||
{
|
{
|
||||||
if (img) {
|
if (img) {
|
||||||
XpmFree(img);
|
XpmFree(img);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
XDestroyImage(XImage *img)
|
XDestroyImage(XImage *img)
|
||||||
{
|
{
|
||||||
if (img) {
|
if (img) {
|
||||||
#if !defined(__VISAGECPP__) /* fixme for OS/2 */
|
|
||||||
DeleteObject(img->bitmap); /* check return ??? */
|
DeleteObject(img->bitmap); /* check return ??? */
|
||||||
#endif
|
|
||||||
XImageFree(img);
|
XImageFree(img);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -39,12 +39,7 @@
|
|||||||
|
|
||||||
#ifdef FOR_MSW
|
#ifdef FOR_MSW
|
||||||
|
|
||||||
#if defined(__OS2__)
|
|
||||||
#define INCL_OS2
|
|
||||||
#include<os2.h>
|
|
||||||
#else
|
|
||||||
#include "windows.h" /* MS windows GDI types */
|
#include "windows.h" /* MS windows GDI types */
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* minimal portability layer between ansi and KR C
|
* minimal portability layer between ansi and KR C
|
||||||
@@ -77,12 +72,7 @@ typedef void *Visual; /* not used yet, is for GRAY, COLOR,
|
|||||||
typedef void *Colormap; /* should be COLORPALETTE, not done
|
typedef void *Colormap; /* should be COLORPALETTE, not done
|
||||||
* yet */
|
* yet */
|
||||||
|
|
||||||
#if !defined(__OS2__)
|
|
||||||
typedef COLORREF Pixel;
|
typedef COLORREF Pixel;
|
||||||
#else
|
|
||||||
typedef unsigned long COLORREF;
|
|
||||||
typedef unsigned long Pixel;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PIXEL_ALREADY_TYPEDEFED /* to let xpm.h know about it */
|
#define PIXEL_ALREADY_TYPEDEFED /* to let xpm.h know about it */
|
||||||
|
|
||||||
@@ -131,18 +121,15 @@ extern "C" {
|
|||||||
#endif /* cplusplus */
|
#endif /* cplusplus */
|
||||||
|
|
||||||
#define ZPixmap 1 /* not really used */
|
#define ZPixmap 1 /* not really used */
|
||||||
|
#define XYBitmap 1 /* not really used */
|
||||||
|
|
||||||
#ifndef True
|
#ifndef True
|
||||||
#define True 1
|
#define True 1
|
||||||
#define False 0
|
#define False 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
#ifndef Bool
|
#ifndef Bool
|
||||||
typedef BOOL Bool;
|
typedef BOOL Bool; /* take MSW bool */
|
||||||
#endif
|
#endif
|
||||||
*/
|
|
||||||
|
|
||||||
/* make these local here, simx.c gets the same from xpm.h */
|
/* make these local here, simx.c gets the same from xpm.h */
|
||||||
#undef LFUNC
|
#undef LFUNC
|
||||||
#undef FUNC
|
#undef FUNC
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************\
|
/*****************************************************************************\
|
||||||
* XpmWrFFrData.c: *
|
* WrFFrData.c: *
|
||||||
* *
|
* *
|
||||||
* XPM library *
|
* XPM library *
|
||||||
* Parse an Xpm array and write a file that corresponds to it. *
|
* Parse an Xpm array and write a file that corresponds to it. *
|
||||||
@@ -32,11 +32,12 @@
|
|||||||
* Developed by Dan Greening dgreen@cs.ucla.edu / dgreen@sti.com *
|
* Developed by Dan Greening dgreen@cs.ucla.edu / dgreen@sti.com *
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
#include "xpm34.h"
|
#include "XpmI.h"
|
||||||
#include "xpm34p.h"
|
|
||||||
|
|
||||||
int
|
int
|
||||||
XpmWriteFileFromData(char *filename, char **data)
|
XpmWriteFileFromData(filename, data)
|
||||||
|
char *filename;
|
||||||
|
char **data;
|
||||||
{
|
{
|
||||||
XpmImage image;
|
XpmImage image;
|
||||||
XpmInfo info;
|
XpmInfo info;
|
||||||
|
167
src/xpm/wrffri.c
167
src/xpm/wrffri.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************\
|
/*****************************************************************************\
|
||||||
* XpmWrFFrI.c: *
|
* WrFFrI.c: *
|
||||||
* *
|
* *
|
||||||
* XPM library *
|
* XPM library *
|
||||||
* Write an image and possibly its mask to an XPM file *
|
* Write an image and possibly its mask to an XPM file *
|
||||||
@@ -32,12 +32,20 @@
|
|||||||
* Developed by Arnaud Le Hors *
|
* Developed by Arnaud Le Hors *
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
#include "xpm34p.h"
|
/*
|
||||||
#ifdef FOR_MSW
|
* The code related to AMIGA has been added by
|
||||||
#include "ctype.h"
|
* Lorens Younes (d93-hyo@nada.kth.se) 4/96
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "XpmI.h"
|
||||||
|
#if !defined(NO_ZPIPE) && defined(WIN32)
|
||||||
|
# define popen _popen
|
||||||
|
# define pclose _pclose
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string.h>
|
/* MS Windows define a function called WriteFile @#%#&!!! */
|
||||||
|
LFUNC(xpmWriteFile, int, (FILE *file, XpmImage *image, char *name,
|
||||||
|
XpmInfo *info));
|
||||||
|
|
||||||
LFUNC(WriteColors, void, (FILE *file, XpmColor *colors, unsigned int ncolors));
|
LFUNC(WriteColors, void, (FILE *file, XpmColor *colors, unsigned int ncolors));
|
||||||
|
|
||||||
@@ -48,8 +56,16 @@ LFUNC(WritePixels, int, (FILE *file, unsigned int width, unsigned int height,
|
|||||||
LFUNC(WriteExtensions, void, (FILE *file, XpmExtension *ext,
|
LFUNC(WriteExtensions, void, (FILE *file, XpmExtension *ext,
|
||||||
unsigned int num));
|
unsigned int num));
|
||||||
|
|
||||||
|
LFUNC(OpenWriteFile, int, (char *filename, xpmData *mdata));
|
||||||
|
LFUNC(xpmDataClose, void, (xpmData *mdata));
|
||||||
|
|
||||||
int
|
int
|
||||||
XpmWriteFileFromImage(Display *display, char *filename, XImage *image, XImage *shapeimage, XpmAttributes *attributes)
|
XpmWriteFileFromImage(display, filename, image, shapeimage, attributes)
|
||||||
|
Display *display;
|
||||||
|
char *filename;
|
||||||
|
XImage *image;
|
||||||
|
XImage *shapeimage;
|
||||||
|
XpmAttributes *attributes;
|
||||||
{
|
{
|
||||||
XpmImage xpmimage;
|
XpmImage xpmimage;
|
||||||
XpmInfo info;
|
XpmInfo info;
|
||||||
@@ -75,15 +91,17 @@ XpmWriteFileFromImage(Display *display, char *filename, XImage *image, XImage *s
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
XpmWriteFileFromXpmImage(char *filename, XpmImage *image, XpmInfo *info)
|
XpmWriteFileFromXpmImage(filename, image, info)
|
||||||
|
char *filename;
|
||||||
|
XpmImage *image;
|
||||||
|
XpmInfo *info;
|
||||||
{
|
{
|
||||||
xpmData mdata;
|
xpmData mdata;
|
||||||
char *name, *dot, *s, new_name[BUFSIZ];
|
char *name, *dot, *s, new_name[BUFSIZ];
|
||||||
int ErrorStatus;
|
int ErrorStatus;
|
||||||
int len, i;
|
|
||||||
|
|
||||||
/* open file to write */
|
/* open file to write */
|
||||||
if ((ErrorStatus = xpmWriteFile(filename, &mdata)) != XpmSuccess)
|
if ((ErrorStatus = OpenWriteFile(filename, &mdata)) != XpmSuccess)
|
||||||
return (ErrorStatus);
|
return (ErrorStatus);
|
||||||
|
|
||||||
/* figure out a name */
|
/* figure out a name */
|
||||||
@@ -91,26 +109,33 @@ XpmWriteFileFromXpmImage(char *filename, XpmImage *image, XpmInfo *info)
|
|||||||
#ifdef VMS
|
#ifdef VMS
|
||||||
name = filename;
|
name = filename;
|
||||||
#else
|
#else
|
||||||
#ifdef FOR_MSW
|
if (!(name = rindex(filename, '/'))
|
||||||
if (!(name = strchr(filename, '\\')))
|
#ifdef AMIGA
|
||||||
#else
|
&& !(name = rindex(filename, ':'))
|
||||||
if (!(name = strchr(filename, '/')))
|
|
||||||
#endif
|
#endif
|
||||||
|
)
|
||||||
name = filename;
|
name = filename;
|
||||||
else
|
else
|
||||||
name++;
|
name++;
|
||||||
#endif
|
#endif
|
||||||
if (dot = strchr(name, '.')) {
|
/* let's try to make a valid C syntax name */
|
||||||
|
if (dot = index(name, '.')) {
|
||||||
strcpy(new_name, name);
|
strcpy(new_name, name);
|
||||||
#ifdef FOR_MSW
|
/* change '.' to '_' */
|
||||||
// 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;
|
name = s = new_name;
|
||||||
while (dot = strchr(s, '.')) {
|
while (dot = index(s, '.')) {
|
||||||
|
*dot = '_';
|
||||||
|
s = dot;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dot = index(name, '-')) {
|
||||||
|
if (name != new_name) {
|
||||||
|
strcpy(new_name, name);
|
||||||
|
name = new_name;
|
||||||
|
}
|
||||||
|
/* change '-' to '_' */
|
||||||
|
s = name;
|
||||||
|
while (dot = index(s, '-')) {
|
||||||
*dot = '_';
|
*dot = '_';
|
||||||
s = dot;
|
s = dot;
|
||||||
}
|
}
|
||||||
@@ -120,24 +145,24 @@ XpmWriteFileFromXpmImage(char *filename, XpmImage *image, XpmInfo *info)
|
|||||||
|
|
||||||
/* write the XpmData from the XpmImage */
|
/* write the XpmData from the XpmImage */
|
||||||
if (ErrorStatus == XpmSuccess)
|
if (ErrorStatus == XpmSuccess)
|
||||||
ErrorStatus = xpmWriteData(&mdata, image, name, info);
|
ErrorStatus = xpmWriteFile(mdata.stream.file, image, name, info);
|
||||||
|
|
||||||
xpmDataClose(&mdata);
|
xpmDataClose(&mdata);
|
||||||
|
|
||||||
return (ErrorStatus);
|
return (ErrorStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
xpmWriteData(xpmData *mdata, XpmImage *image, char *name, XpmInfo *info)
|
xpmWriteFile(file, image, name, info)
|
||||||
|
FILE *file;
|
||||||
|
XpmImage *image;
|
||||||
|
char *name;
|
||||||
|
XpmInfo *info;
|
||||||
{
|
{
|
||||||
/* calculation variables */
|
/* calculation variables */
|
||||||
unsigned int cmts, extensions;
|
unsigned int cmts, extensions;
|
||||||
FILE *file;
|
|
||||||
int ErrorStatus;
|
int ErrorStatus;
|
||||||
|
|
||||||
/* store this to speed up */
|
|
||||||
file = mdata->stream.file;
|
|
||||||
|
|
||||||
cmts = info && (info->valuemask & XpmComments);
|
cmts = info && (info->valuemask & XpmComments);
|
||||||
extensions = info && (info->valuemask & XpmExtensions)
|
extensions = info && (info->valuemask & XpmExtensions)
|
||||||
&& info->nextensions;
|
&& info->nextensions;
|
||||||
@@ -186,7 +211,10 @@ xpmWriteData(xpmData *mdata, XpmImage *image, char *name, XpmInfo *info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
WriteColors(FILE *file, XpmColor *colors, unsigned int ncolors)
|
WriteColors(file, colors, ncolors)
|
||||||
|
FILE *file;
|
||||||
|
XpmColor *colors;
|
||||||
|
unsigned int ncolors;
|
||||||
{
|
{
|
||||||
unsigned int a, key;
|
unsigned int a, key;
|
||||||
char *s;
|
char *s;
|
||||||
@@ -207,7 +235,13 @@ WriteColors(FILE *file, XpmColor *colors, unsigned int ncolors)
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
WritePixels(FILE *file, unsigned int width, unsigned int height, unsigned int cpp, unsigned int *pixels, XpmColor *colors)
|
WritePixels(file, width, height, cpp, pixels, colors)
|
||||||
|
FILE *file;
|
||||||
|
unsigned int width;
|
||||||
|
unsigned int height;
|
||||||
|
unsigned int cpp;
|
||||||
|
unsigned int *pixels;
|
||||||
|
XpmColor *colors;
|
||||||
{
|
{
|
||||||
char *s, *p, *buf;
|
char *s, *p, *buf;
|
||||||
unsigned int x, y, h;
|
unsigned int x, y, h;
|
||||||
@@ -243,7 +277,10 @@ WritePixels(FILE *file, unsigned int width, unsigned int height, unsigned int cp
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
WriteExtensions(FILE *file, XpmExtension *ext, unsigned int num)
|
WriteExtensions(file, ext, num)
|
||||||
|
FILE *file;
|
||||||
|
XpmExtension *ext;
|
||||||
|
unsigned int num;
|
||||||
{
|
{
|
||||||
unsigned int x, y, n;
|
unsigned int x, y, n;
|
||||||
char **line;
|
char **line;
|
||||||
@@ -256,3 +293,67 @@ WriteExtensions(FILE *file, XpmExtension *ext, unsigned int num)
|
|||||||
}
|
}
|
||||||
fprintf(file, ",\n\"XPMENDEXT\"");
|
fprintf(file, ",\n\"XPMENDEXT\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* open the given file to be written as an xpmData which is returned
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
OpenWriteFile(filename, mdata)
|
||||||
|
char *filename;
|
||||||
|
xpmData *mdata;
|
||||||
|
{
|
||||||
|
#ifndef NO_ZPIPE
|
||||||
|
char buf[BUFSIZ];
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!filename) {
|
||||||
|
mdata->stream.file = (stdout);
|
||||||
|
mdata->type = XPMFILE;
|
||||||
|
} else {
|
||||||
|
#ifndef NO_ZPIPE
|
||||||
|
int len = strlen(filename);
|
||||||
|
if (len > 2 && !strcmp(".Z", filename + (len - 2))) {
|
||||||
|
sprintf(buf, "compress > \"%s\"", filename);
|
||||||
|
if (!(mdata->stream.file = popen(buf, "w")))
|
||||||
|
return (XpmOpenFailed);
|
||||||
|
|
||||||
|
mdata->type = XPMPIPE;
|
||||||
|
} else if (len > 3 && !strcmp(".gz", filename + (len - 3))) {
|
||||||
|
sprintf(buf, "gzip -q > \"%s\"", filename);
|
||||||
|
if (!(mdata->stream.file = popen(buf, "w")))
|
||||||
|
return (XpmOpenFailed);
|
||||||
|
|
||||||
|
mdata->type = XPMPIPE;
|
||||||
|
} else {
|
||||||
|
#endif
|
||||||
|
if (!(mdata->stream.file = fopen(filename, "w")))
|
||||||
|
return (XpmOpenFailed);
|
||||||
|
|
||||||
|
mdata->type = XPMFILE;
|
||||||
|
#ifndef NO_ZPIPE
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return (XpmSuccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* close the file related to the xpmData if any
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
xpmDataClose(mdata)
|
||||||
|
xpmData *mdata;
|
||||||
|
{
|
||||||
|
switch (mdata->type) {
|
||||||
|
case XPMFILE:
|
||||||
|
if (mdata->stream.file != (stdout))
|
||||||
|
fclose(mdata->stream.file);
|
||||||
|
break;
|
||||||
|
#ifndef NO_ZPIPE
|
||||||
|
case XPMPIPE:
|
||||||
|
pclose(mdata->stream.file);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -1,83 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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
|
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -37,6 +37,11 @@
|
|||||||
* HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
|
* HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The code related to AMIGA has been added by
|
||||||
|
* Lorens Younes (d93-hyo@nada.kth.se) 4/96
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef XPM_h
|
#ifndef XPM_h
|
||||||
#define XPM_h
|
#define XPM_h
|
||||||
|
|
||||||
@@ -50,7 +55,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* first some identification numbers:
|
* first some identification numbers:
|
||||||
* the following revision numbers is determined with the following rule:
|
* the version and revision numbers are determined with the following rule:
|
||||||
* SO Major number = LIB minor version number.
|
* SO Major number = LIB minor version number.
|
||||||
* SO Minor number = LIB sub-minor version number.
|
* SO Minor number = LIB sub-minor version number.
|
||||||
* e.g: Xpm version 3.2f
|
* e.g: Xpm version 3.2f
|
||||||
@@ -58,41 +63,45 @@
|
|||||||
* thus we have XpmVersion = 2 and XpmRevision = 6
|
* thus we have XpmVersion = 2 and XpmRevision = 6
|
||||||
* which gives SOXPMLIBREV = 2.6
|
* which gives SOXPMLIBREV = 2.6
|
||||||
*
|
*
|
||||||
* Then the XpmIncludeVersion number is built with the following rule:
|
* Then the XpmIncludeVersion number is built from these numbers.
|
||||||
* (XpmFormat*100 + XpmVersion)*100 + XpmRevision
|
|
||||||
*/
|
*/
|
||||||
#define XpmFormat 3
|
#define XpmFormat 3
|
||||||
#define XpmVersion 4
|
#define XpmVersion 4
|
||||||
#define XpmRevision 2
|
#define XpmRevision 11
|
||||||
|
#define XpmIncludeVersion ((XpmFormat * 100 + XpmVersion) * 100 + XpmRevision)
|
||||||
#define XpmIncludeVersion 30402
|
|
||||||
|
|
||||||
#ifndef XPM_NUMBERS
|
#ifndef XPM_NUMBERS
|
||||||
|
|
||||||
#ifdef VMS
|
|
||||||
#include "decw$include:Xlib.h"
|
|
||||||
#include "decw$include:Xutil.h"
|
|
||||||
#else /* VMS */
|
|
||||||
#ifdef FOR_MSW
|
#ifdef FOR_MSW
|
||||||
#define SYSV /* uses memcpy string.h etc. */
|
# define SYSV /* uses memcpy string.h etc. */
|
||||||
#include <malloc.h>
|
# include <malloc.h>
|
||||||
#include "simx.h" /* defines some X stuff using MSW types */
|
# include "simx.h" /* defines some X stuff using MSW types */
|
||||||
#ifndef __GNUWIN32__
|
|
||||||
#define NEED_STRCASECMP /* at least for MSVC++ */
|
#define NEED_STRCASECMP /* at least for MSVC++ */
|
||||||
#endif
|
|
||||||
#else /* FOR_MSW */
|
#else /* FOR_MSW */
|
||||||
#include <X11/Xlib.h>
|
# ifdef AMIGA
|
||||||
#include <X11/Xutil.h>
|
# include "amigax.h"
|
||||||
#include <stdlib.h> /* HEDU */
|
# else /* not AMIGA */
|
||||||
|
# include <X11/Xlib.h>
|
||||||
|
# include <X11/Xutil.h>
|
||||||
|
# endif /* not AMIGA */
|
||||||
#endif /* FOR_MSW */
|
#endif /* FOR_MSW */
|
||||||
#endif /* VMS */
|
|
||||||
|
|
||||||
/* let's define Pixel if it is not done yet */
|
/* let's define Pixel if it is not done yet */
|
||||||
#if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
|
#if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
|
||||||
typedef unsigned long Pixel; /* Index into colormap */
|
typedef unsigned long Pixel; /* Index into colormap */
|
||||||
#define PIXEL_ALREADY_TYPEDEFED
|
# define PIXEL_ALREADY_TYPEDEFED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* make sure we know whether function prototypes are needed or not */
|
||||||
|
#ifndef NeedFunctionPrototypes
|
||||||
|
# if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
|
||||||
|
# define NeedFunctionPrototypes 1
|
||||||
|
# else
|
||||||
|
# define NeedFunctionPrototypes 0
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Return ErrorStatus codes:
|
/* Return ErrorStatus codes:
|
||||||
* null if full success
|
* null if full success
|
||||||
* positive if partial success
|
* positive if partial success
|
||||||
@@ -106,9 +115,6 @@ typedef unsigned long Pixel; /* Index into colormap */
|
|||||||
#define XpmNoMemory -3
|
#define XpmNoMemory -3
|
||||||
#define XpmColorFailed -4
|
#define XpmColorFailed -4
|
||||||
|
|
||||||
/* the following should help people wanting to use their own functions */
|
|
||||||
#define XpmFree(ptr) free(ptr)
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name; /* Symbolic color name */
|
char *name; /* Symbolic color name */
|
||||||
char *value; /* Color value */
|
char *value; /* Color value */
|
||||||
@@ -150,50 +156,86 @@ typedef struct {
|
|||||||
XpmExtension *extensions; /* pointer to array of extensions */
|
XpmExtension *extensions; /* pointer to array of extensions */
|
||||||
} XpmInfo;
|
} XpmInfo;
|
||||||
|
|
||||||
|
typedef int (*XpmAllocColorFunc)(
|
||||||
|
#if NeedFunctionPrototypes
|
||||||
|
Display* /* display */,
|
||||||
|
Colormap /* colormap */,
|
||||||
|
char* /* colorname */,
|
||||||
|
XColor* /* xcolor */,
|
||||||
|
void* /* closure */
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
|
typedef int (*XpmFreeColorsFunc)(
|
||||||
|
#if NeedFunctionPrototypes
|
||||||
|
Display* /* display */,
|
||||||
|
Colormap /* colormap */,
|
||||||
|
Pixel* /* pixels */,
|
||||||
|
int /* npixels */,
|
||||||
|
void* /* closure */
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned long valuemask; /* Specifies which attributes are
|
unsigned long valuemask; /* Specifies which attributes are
|
||||||
* defined */
|
defined */
|
||||||
|
|
||||||
Visual *visual; /* Specifies the visual to use */
|
Visual *visual; /* Specifies the visual to use */
|
||||||
Colormap colormap; /* Specifies the colormap to use */
|
Colormap colormap; /* Specifies the colormap to use */
|
||||||
unsigned int depth; /* Specifies the depth */
|
unsigned int depth; /* Specifies the depth */
|
||||||
unsigned int width; /* Returns the width of the created
|
unsigned int width; /* Returns the width of the created
|
||||||
* pixmap */
|
pixmap */
|
||||||
unsigned int height; /* Returns the height of the created
|
unsigned int height; /* Returns the height of the created
|
||||||
* pixmap */
|
pixmap */
|
||||||
unsigned int x_hotspot; /* Returns the x hotspot's
|
unsigned int x_hotspot; /* Returns the x hotspot's
|
||||||
* coordinate */
|
coordinate */
|
||||||
unsigned int y_hotspot; /* Returns the y hotspot's
|
unsigned int y_hotspot; /* Returns the y hotspot's
|
||||||
* coordinate */
|
coordinate */
|
||||||
unsigned int cpp; /* Specifies the number of char per
|
unsigned int cpp; /* Specifies the number of char per
|
||||||
* pixel */
|
pixel */
|
||||||
Pixel *pixels; /* List of used color pixels */
|
Pixel *pixels; /* List of used color pixels */
|
||||||
unsigned int npixels; /* Number of pixels */
|
unsigned int npixels; /* Number of used pixels */
|
||||||
XpmColorSymbol *colorsymbols; /* Array of color symbols to
|
XpmColorSymbol *colorsymbols; /* List of color symbols to override */
|
||||||
* override */
|
|
||||||
unsigned int numsymbols; /* Number of symbols */
|
unsigned int numsymbols; /* Number of symbols */
|
||||||
char *rgb_fname; /* RGB text file name */
|
char *rgb_fname; /* RGB text file name */
|
||||||
unsigned int nextensions; /* number of extensions */
|
unsigned int nextensions; /* Number of extensions */
|
||||||
XpmExtension *extensions; /* pointer to array of extensions */
|
XpmExtension *extensions; /* List of extensions */
|
||||||
|
|
||||||
unsigned int ncolors; /* Number of colors */
|
unsigned int ncolors; /* Number of colors */
|
||||||
XpmColor *colorTable; /* Color table pointer */
|
XpmColor *colorTable; /* List of colors */
|
||||||
/* 3.2 backward compatibility code */
|
/* 3.2 backward compatibility code */
|
||||||
char *hints_cmt; /* Comment of the hints section */
|
char *hints_cmt; /* Comment of the hints section */
|
||||||
char *colors_cmt; /* Comment of the colors section */
|
char *colors_cmt; /* Comment of the colors section */
|
||||||
char *pixels_cmt; /* Comment of the pixels section */
|
char *pixels_cmt; /* Comment of the pixels section */
|
||||||
/* end 3.2 bc */
|
/* end 3.2 bc */
|
||||||
unsigned int mask_pixel; /* Transparent pixel's color table
|
unsigned int mask_pixel; /* Color table index of transparent
|
||||||
* index */
|
color */
|
||||||
|
|
||||||
/* Color Allocation Directives */
|
/* Color Allocation Directives */
|
||||||
unsigned int exactColors; /* Only use exact colors for visual */
|
Bool exactColors; /* Only use exact colors for visual */
|
||||||
unsigned int closeness; /* Allowable RGB deviation */
|
unsigned int closeness; /* Allowable RGB deviation */
|
||||||
unsigned int red_closeness; /* Allowable red deviation */
|
unsigned int red_closeness; /* Allowable red deviation */
|
||||||
unsigned int green_closeness; /* Allowable green deviation */
|
unsigned int green_closeness; /* Allowable green deviation */
|
||||||
unsigned int blue_closeness; /* Allowable blue deviation */
|
unsigned int blue_closeness; /* Allowable blue deviation */
|
||||||
int color_key; /* Use colors from this color set */
|
int color_key; /* Use colors from this color set */
|
||||||
|
|
||||||
|
Pixel *alloc_pixels; /* Returns the list of alloc'ed color
|
||||||
|
pixels */
|
||||||
|
int nalloc_pixels; /* Returns the number of alloc'ed
|
||||||
|
color pixels */
|
||||||
|
|
||||||
|
Bool alloc_close_colors; /* Specify whether close colors should
|
||||||
|
be allocated using XAllocColor
|
||||||
|
or not */
|
||||||
|
int bitmap_format; /* Specify the format of 1bit depth
|
||||||
|
images: ZPixmap or XYBitmap */
|
||||||
|
|
||||||
|
/* Color functions */
|
||||||
|
XpmAllocColorFunc alloc_color; /* Application color allocator */
|
||||||
|
XpmFreeColorsFunc free_colors; /* Application color de-allocator */
|
||||||
|
void *color_closure; /* Application private data to pass to
|
||||||
|
alloc_color and free_colors */
|
||||||
|
|
||||||
} XpmAttributes;
|
} XpmAttributes;
|
||||||
|
|
||||||
/* XpmAttributes value masks bits */
|
/* XpmAttributes value masks bits */
|
||||||
@@ -221,6 +263,15 @@ typedef struct {
|
|||||||
#define XpmColorTable (1L<<15)
|
#define XpmColorTable (1L<<15)
|
||||||
#define XpmReturnColorTable XpmColorTable
|
#define XpmReturnColorTable XpmColorTable
|
||||||
|
|
||||||
|
#define XpmReturnAllocPixels (1L<<16)
|
||||||
|
#define XpmAllocCloseColors (1L<<17)
|
||||||
|
#define XpmBitmapFormat (1L<<18)
|
||||||
|
|
||||||
|
#define XpmAllocColor (1L<<19)
|
||||||
|
#define XpmFreeColors (1L<<20)
|
||||||
|
#define XpmColorClosure (1L<<21)
|
||||||
|
|
||||||
|
|
||||||
/* XpmInfo value masks bits */
|
/* XpmInfo value masks bits */
|
||||||
#define XpmComments XpmInfos
|
#define XpmComments XpmInfos
|
||||||
#define XpmReturnComments XpmComments
|
#define XpmReturnComments XpmComments
|
||||||
@@ -235,7 +286,7 @@ typedef struct {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* color keys for visual type, they must fit along with the number key of
|
* color keys for visual type, they must fit along with the number key of
|
||||||
* each related element in xpmColorKeys[] defined in xpmP.h
|
* each related element in xpmColorKeys[] defined in XpmI.h
|
||||||
*/
|
*/
|
||||||
#define XPM_MONO 2
|
#define XPM_MONO 2
|
||||||
#define XPM_GREY4 3
|
#define XPM_GREY4 3
|
||||||
@@ -245,22 +296,14 @@ typedef struct {
|
|||||||
#define XPM_COLOR 5
|
#define XPM_COLOR 5
|
||||||
|
|
||||||
|
|
||||||
/*
|
/* macros for forward declarations of functions with prototypes */
|
||||||
* minimal portability layer between ansi and KR C
|
#if NeedFunctionPrototypes
|
||||||
*/
|
|
||||||
|
|
||||||
/* forward declaration of functions with prototypes */
|
|
||||||
|
|
||||||
#if __STDC__ || defined(__cplusplus) || defined(c_plusplus)
|
|
||||||
/* ANSI || C++ */
|
|
||||||
#define FUNC(f, t, p) extern t f p
|
#define FUNC(f, t, p) extern t f p
|
||||||
#define LFUNC(f, t, p) static t f p
|
#define LFUNC(f, t, p) static t f p
|
||||||
/* #define LFUNC(f, t, p) t f p */
|
#else
|
||||||
#else /* K&R */
|
|
||||||
#define FUNC(f, t, p) extern t f()
|
#define FUNC(f, t, p) extern t f()
|
||||||
#define LFUNC(f, t, p) static t f()
|
#define LFUNC(f, t, p) static t f()
|
||||||
/* #define LFUNC(f, t, p) t f() */
|
#endif
|
||||||
#endif /* end of K&R */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -271,103 +314,10 @@ typedef struct {
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* For Microsoft C++ at any rate, the FUNC macro just doesn't work: it causes
|
|
||||||
* arguments to be corrupted espec. in XpmWriteFileFromXpmImage.
|
|
||||||
* So, define all prototypes explicitly.
|
|
||||||
*/
|
|
||||||
#if defined(_MSC_VER) || defined(__OS2__)
|
|
||||||
|
|
||||||
/* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
|
/* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
|
||||||
|
/* Same for Amiga! */
|
||||||
|
|
||||||
int XpmCreateImageFromData(Display *display,
|
#if !defined(FOR_MSW) && !defined(AMIGA)
|
||||||
char **data,
|
|
||||||
XImage **image_return,
|
|
||||||
XImage **shapemask_return,
|
|
||||||
XpmAttributes *attributes);
|
|
||||||
|
|
||||||
int XpmCreateDataFromImage(Display *display,
|
|
||||||
char ***data_return,
|
|
||||||
XImage *image,
|
|
||||||
XImage *shapeimage,
|
|
||||||
XpmAttributes *attributes);
|
|
||||||
|
|
||||||
int XpmReadFileToImage(Display *display,
|
|
||||||
char *filename,
|
|
||||||
XImage **image_return,
|
|
||||||
XImage **shapeimage_return,
|
|
||||||
XpmAttributes *attributes);
|
|
||||||
|
|
||||||
int XpmWriteFileFromImage(Display *display,
|
|
||||||
char *filename,
|
|
||||||
XImage *image,
|
|
||||||
XImage *shapeimage,
|
|
||||||
XpmAttributes *attributes);
|
|
||||||
|
|
||||||
int XpmCreateImageFromBuffer(Display *display,
|
|
||||||
char *buffer,
|
|
||||||
XImage **image_return,
|
|
||||||
XImage **shapemask_return,
|
|
||||||
XpmAttributes *attributes);
|
|
||||||
|
|
||||||
int XpmReadFileToBuffer(char *filename, char **buffer_return);
|
|
||||||
int XpmWriteFileFromBuffer(char *filename, char *buffer);
|
|
||||||
|
|
||||||
int XpmReadFileToData(char *filename, char ***data_return);
|
|
||||||
int XpmWriteFileFromData(char *filename, char **data);
|
|
||||||
|
|
||||||
int XpmAttributesSize();
|
|
||||||
void XpmFreeAttributes(XpmAttributes *attributes);
|
|
||||||
void XpmFreeExtensions(XpmExtension *extensions,
|
|
||||||
int nextensions);
|
|
||||||
|
|
||||||
void XpmFreeXpmImage(XpmImage *image);
|
|
||||||
void XpmFreeXpmInfo(XpmInfo *info);
|
|
||||||
char *XpmGetErrorString(int errcode);
|
|
||||||
int XpmLibraryVersion();
|
|
||||||
|
|
||||||
/* XpmImage functions */
|
|
||||||
int XpmReadFileToXpmImage(char *filename,
|
|
||||||
XpmImage *image,
|
|
||||||
XpmInfo *info);
|
|
||||||
|
|
||||||
int XpmWriteFileFromXpmImage(char *filename,
|
|
||||||
XpmImage *image,
|
|
||||||
XpmInfo *info);
|
|
||||||
|
|
||||||
int XpmWriteFileFromXpmImage(char *filename, XpmImage *image, XpmInfo *info);
|
|
||||||
|
|
||||||
int XpmCreateImageFromXpmImage(Display *display,
|
|
||||||
XpmImage *image,
|
|
||||||
XImage **image_return,
|
|
||||||
XImage **shapeimage_return,
|
|
||||||
XpmAttributes *attributes);
|
|
||||||
|
|
||||||
int XpmCreateXpmImageFromImage(Display *display,
|
|
||||||
XImage *image,
|
|
||||||
XImage *shapeimage,
|
|
||||||
XpmImage *xpmimage,
|
|
||||||
XpmAttributes *attributes);
|
|
||||||
int XpmCreateDataFromXpmImage(char ***data_return,
|
|
||||||
XpmImage *image,
|
|
||||||
XpmInfo *info);
|
|
||||||
|
|
||||||
int XpmCreateXpmImageFromData(char **data,
|
|
||||||
XpmImage *image,
|
|
||||||
XpmInfo *info);
|
|
||||||
|
|
||||||
int XpmCreateXpmImageFromBuffer(char *buffer,
|
|
||||||
XpmImage *image,
|
|
||||||
XpmInfo *info);
|
|
||||||
|
|
||||||
int XpmCreateBufferFromXpmImage(char **buffer_return,
|
|
||||||
XpmImage *image,
|
|
||||||
XpmInfo *info);
|
|
||||||
|
|
||||||
#else // _MSC_VER
|
|
||||||
|
|
||||||
/* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
|
|
||||||
|
|
||||||
#ifndef FOR_MSW
|
|
||||||
FUNC(XpmCreatePixmapFromData, int, (Display *display,
|
FUNC(XpmCreatePixmapFromData, int, (Display *display,
|
||||||
Drawable d,
|
Drawable d,
|
||||||
char **data,
|
char **data,
|
||||||
@@ -393,7 +343,7 @@ extern "C" {
|
|||||||
Pixmap pixmap,
|
Pixmap pixmap,
|
||||||
Pixmap shapemask,
|
Pixmap shapemask,
|
||||||
XpmAttributes *attributes));
|
XpmAttributes *attributes));
|
||||||
#endif /* ndef FOR_MSW */
|
#endif
|
||||||
|
|
||||||
FUNC(XpmCreateImageFromData, int, (Display *display,
|
FUNC(XpmCreateImageFromData, int, (Display *display,
|
||||||
char **data,
|
char **data,
|
||||||
@@ -424,7 +374,7 @@ extern "C" {
|
|||||||
XImage **image_return,
|
XImage **image_return,
|
||||||
XImage **shapemask_return,
|
XImage **shapemask_return,
|
||||||
XpmAttributes *attributes));
|
XpmAttributes *attributes));
|
||||||
#ifndef FOR_MSW
|
#if !defined(FOR_MSW) && !defined(AMIGA)
|
||||||
FUNC(XpmCreatePixmapFromBuffer, int, (Display *display,
|
FUNC(XpmCreatePixmapFromBuffer, int, (Display *display,
|
||||||
Drawable d,
|
Drawable d,
|
||||||
char *buffer,
|
char *buffer,
|
||||||
@@ -443,7 +393,7 @@ extern "C" {
|
|||||||
Pixmap pixmap,
|
Pixmap pixmap,
|
||||||
Pixmap shapemask,
|
Pixmap shapemask,
|
||||||
XpmAttributes *attributes));
|
XpmAttributes *attributes));
|
||||||
#endif /* ndef FOR_MSW */
|
#endif
|
||||||
FUNC(XpmReadFileToBuffer, int, (char *filename, char **buffer_return));
|
FUNC(XpmReadFileToBuffer, int, (char *filename, char **buffer_return));
|
||||||
FUNC(XpmWriteFileFromBuffer, int, (char *filename, char *buffer));
|
FUNC(XpmWriteFileFromBuffer, int, (char *filename, char *buffer));
|
||||||
|
|
||||||
@@ -468,11 +418,7 @@ extern "C" {
|
|||||||
FUNC(XpmWriteFileFromXpmImage, int, (char *filename,
|
FUNC(XpmWriteFileFromXpmImage, int, (char *filename,
|
||||||
XpmImage *image,
|
XpmImage *image,
|
||||||
XpmInfo *info));
|
XpmInfo *info));
|
||||||
|
#if !defined(FOR_MSW) && !defined(AMIGA)
|
||||||
FUNC(XpmWriteFileFromXpmImage, int, (char *filename, XpmImage *image, XpmInfo *info));
|
|
||||||
/* extern int XpmWriteFileFromXpmImage(char *filename, XpmImage *image, XpmInfo *info); */
|
|
||||||
|
|
||||||
#ifndef FOR_MSW
|
|
||||||
FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display,
|
FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display,
|
||||||
Drawable d,
|
Drawable d,
|
||||||
XpmImage *image,
|
XpmImage *image,
|
||||||
@@ -491,7 +437,7 @@ extern "C" {
|
|||||||
XImage *shapeimage,
|
XImage *shapeimage,
|
||||||
XpmImage *xpmimage,
|
XpmImage *xpmimage,
|
||||||
XpmAttributes *attributes));
|
XpmAttributes *attributes));
|
||||||
#ifndef FOR_MSW
|
#if !defined(FOR_MSW) && !defined(AMIGA)
|
||||||
FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display,
|
FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display,
|
||||||
Pixmap pixmap,
|
Pixmap pixmap,
|
||||||
Pixmap shapemask,
|
Pixmap shapemask,
|
||||||
@@ -514,8 +460,12 @@ extern "C" {
|
|||||||
XpmImage *image,
|
XpmImage *image,
|
||||||
XpmInfo *info));
|
XpmInfo *info));
|
||||||
|
|
||||||
#endif // _MSC_VER
|
FUNC(XpmGetParseError, int, (char *filename,
|
||||||
|
int *linenum_return,
|
||||||
|
int *charnum_return));
|
||||||
|
|
||||||
|
FUNC(XpmFree, void, (void *ptr));
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} /* for C++ V2.0 */
|
} /* for C++ V2.0 */
|
||||||
#endif
|
#endif
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 1989-94 GROUPE BULL
|
* Copyright (C) 1989-95 GROUPE BULL
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to
|
* of this software and associated documentation files (the "Software"), to
|
||||||
@@ -24,10 +24,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************\
|
/*****************************************************************************\
|
||||||
* xpmP.h: *
|
* XpmI.h: *
|
||||||
* *
|
* *
|
||||||
* XPM library *
|
* XPM library *
|
||||||
* Private Include file *
|
* Internal Include file *
|
||||||
|
* *
|
||||||
|
* ** Everything defined here is subject to changes any time. ** *
|
||||||
* *
|
* *
|
||||||
* Developed by Arnaud Le Hors *
|
* Developed by Arnaud Le Hors *
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
@@ -37,28 +39,23 @@
|
|||||||
* HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
|
* HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef XPMP_h
|
#ifndef XPMI_h
|
||||||
#define XPMP_h
|
#define XPMI_h
|
||||||
|
|
||||||
#include "xpm34.h"
|
#include "xpm.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* lets try to solve include files
|
* lets try to solve include files
|
||||||
*/
|
*/
|
||||||
#ifdef VMS
|
|
||||||
|
|
||||||
#include "sys$library:stdio.h"
|
|
||||||
#include "sys$library:string.h"
|
|
||||||
|
|
||||||
#else /* VMS */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
/* stdio.h doesn't declare popen on a Sequent DYNIX OS */
|
/* stdio.h doesn't declare popen on a Sequent DYNIX OS */
|
||||||
#ifdef sequent
|
#ifdef sequent
|
||||||
extern FILE *popen();
|
extern FILE *popen();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SYSV) || defined(SVR4)
|
#if defined(SYSV) || defined(SVR4) || defined(VMS) || defined(WIN32)
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef index
|
#ifndef index
|
||||||
@@ -69,20 +66,42 @@ extern FILE *popen();
|
|||||||
#define rindex strrchr
|
#define rindex strrchr
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else /* defined(SYSV) || defined(SVR4) */
|
#else /* defined(SYSV) || defined(SVR4) || defined(VMS) */
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* VMS */
|
|
||||||
|
|
||||||
|
|
||||||
#if (defined(SYSV) || defined(SVR4) || defined(VMS)) && !defined(__sgi)
|
#if defined(SYSV) || defined(SVR4) || defined(VMS) || defined(WIN32)
|
||||||
|
#ifndef bcopy
|
||||||
#define bcopy(source, dest, count) memcpy(dest, source, count)
|
#define bcopy(source, dest, count) memcpy(dest, source, count)
|
||||||
|
#endif
|
||||||
|
#ifndef bzero
|
||||||
#define bzero(b, len) memset(b, 0, len)
|
#define bzero(b, len) memset(b, 0, len)
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* the following is defined in X11R6 but not in previous versions */
|
||||||
|
#ifdef __alpha
|
||||||
|
#ifndef LONG64
|
||||||
|
#define LONG64
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef VMS
|
||||||
|
#include <unixio.h>
|
||||||
|
#include <file.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The following should help people wanting to use their own memory allocation
|
||||||
|
* functions. To avoid the overhead of a function call when the standard
|
||||||
|
* functions are used these are all macros, even the XpmFree function which
|
||||||
|
* needs to be a real function for the outside world though.
|
||||||
|
* So if change these be sure to change the XpmFree function in misc.c
|
||||||
|
* accordingly.
|
||||||
|
*/
|
||||||
|
#define XpmFree(ptr) free(ptr)
|
||||||
|
|
||||||
/* the following should help people wanting to use their own functions */
|
|
||||||
#ifndef FOR_MSW
|
#ifndef FOR_MSW
|
||||||
#define XpmMalloc(size) malloc((size))
|
#define XpmMalloc(size) malloc((size))
|
||||||
#define XpmRealloc(ptr, size) realloc((ptr), (size))
|
#define XpmRealloc(ptr, size) realloc((ptr), (size))
|
||||||
@@ -95,7 +114,7 @@ extern FILE *popen();
|
|||||||
boundCheckingCalloc((long)(nelem),(long) (elsize))
|
boundCheckingCalloc((long)(nelem),(long) (elsize))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define XPMMAXCMTLEN BUFSIZ
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned int type;
|
unsigned int type;
|
||||||
union {
|
union {
|
||||||
@@ -105,9 +124,13 @@ typedef struct {
|
|||||||
char *cptr;
|
char *cptr;
|
||||||
unsigned int line;
|
unsigned int line;
|
||||||
int CommentLength;
|
int CommentLength;
|
||||||
char Comment[BUFSIZ];
|
char Comment[XPMMAXCMTLEN];
|
||||||
char *Bcmt, *Ecmt, Bos, Eos;
|
char *Bcmt, *Ecmt, Bos, Eos;
|
||||||
int format; /* 1 if XPM1, 0 otherwise */
|
int format; /* 1 if XPM1, 0 otherwise */
|
||||||
|
#ifdef CXPMPROG
|
||||||
|
int lineNum;
|
||||||
|
int charNum;
|
||||||
|
#endif
|
||||||
} xpmData;
|
} xpmData;
|
||||||
|
|
||||||
#define XPMARRAY 0
|
#define XPMARRAY 0
|
||||||
@@ -152,12 +175,14 @@ extern char *xpmColorKeys[];
|
|||||||
/* number of xpmColorKeys */
|
/* number of xpmColorKeys */
|
||||||
#define NKEYS 5
|
#define NKEYS 5
|
||||||
|
|
||||||
/* XPM private routines */
|
/* XPM internal routines */
|
||||||
|
|
||||||
FUNC(xpmWriteData, int, (xpmData *mdata, XpmImage *image, char *name,
|
|
||||||
XpmInfo *info));
|
|
||||||
|
|
||||||
FUNC(xpmParseData, int, (xpmData *data, XpmImage *image, XpmInfo *info));
|
FUNC(xpmParseData, int, (xpmData *data, XpmImage *image, XpmInfo *info));
|
||||||
|
FUNC(xpmParseDataAndCreate, int, (Display *display, xpmData *data,
|
||||||
|
XImage **image_return,
|
||||||
|
XImage **shapeimage_return,
|
||||||
|
XpmImage *image, XpmInfo *info,
|
||||||
|
XpmAttributes *attributes));
|
||||||
|
|
||||||
FUNC(xpmFreeColorTable, void, (XpmColor *colorTable, int ncolors));
|
FUNC(xpmFreeColorTable, void, (XpmColor *colorTable, int ncolors));
|
||||||
|
|
||||||
@@ -172,7 +197,7 @@ FUNC(xpmSetInfo, void, (XpmInfo *info, XpmAttributes *attributes));
|
|||||||
FUNC(xpmSetAttributes, void, (XpmAttributes *attributes, XpmImage *image,
|
FUNC(xpmSetAttributes, void, (XpmAttributes *attributes, XpmImage *image,
|
||||||
XpmInfo *info));
|
XpmInfo *info));
|
||||||
|
|
||||||
#ifndef FOR_MSW
|
#if !defined(FOR_MSW) && !defined(AMIGA)
|
||||||
FUNC(xpmCreatePixmapFromImage, void, (Display *display, Drawable d,
|
FUNC(xpmCreatePixmapFromImage, void, (Display *display, Drawable d,
|
||||||
XImage *ximage, Pixmap *pixmap_return));
|
XImage *ximage, Pixmap *pixmap_return));
|
||||||
|
|
||||||
@@ -182,6 +207,29 @@ FUNC(xpmCreateImageFromPixmap, void, (Display *display, Pixmap pixmap,
|
|||||||
unsigned int *height));
|
unsigned int *height));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* 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)
|
||||||
|
|
||||||
/* I/O utility */
|
/* I/O utility */
|
||||||
|
|
||||||
FUNC(xpmNextString, int, (xpmData *mdata));
|
FUNC(xpmNextString, int, (xpmData *mdata));
|
||||||
@@ -195,12 +243,19 @@ FUNC(xpmGetString, int, (xpmData *mdata, char **sptr, unsigned int *l));
|
|||||||
FUNC(xpmNextWord, unsigned int,
|
FUNC(xpmNextWord, unsigned int,
|
||||||
(xpmData *mdata, char *buf, unsigned int buflen));
|
(xpmData *mdata, char *buf, unsigned int buflen));
|
||||||
FUNC(xpmGetCmt, int, (xpmData *mdata, char **cmt));
|
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(xpmParseHeader, int, (xpmData *mdata));
|
||||||
FUNC(xpmOpenBuffer, void, (char *buffer, xpmData *mdata));
|
FUNC(xpmParseValues, int, (xpmData *data, unsigned int *width,
|
||||||
|
unsigned int *height, unsigned int *ncolors,
|
||||||
|
unsigned int *cpp, unsigned int *x_hotspot,
|
||||||
|
unsigned int *y_hotspot, unsigned int *hotspot,
|
||||||
|
unsigned int *extensions));
|
||||||
|
|
||||||
|
FUNC(xpmParseColors, int, (xpmData *data, unsigned int ncolors,
|
||||||
|
unsigned int cpp, XpmColor **colorTablePtr,
|
||||||
|
xpmHashTable *hashtable));
|
||||||
|
|
||||||
|
FUNC(xpmParseExtensions, int, (xpmData *data, XpmExtension **extensions,
|
||||||
|
unsigned int *nextensions));
|
||||||
|
|
||||||
/* RGB utility */
|
/* RGB utility */
|
||||||
|
|
||||||
@@ -212,6 +267,7 @@ FUNC(xpmFreeRgbNames, void, (xpmRgbName *rgbn, int rgbn_max));
|
|||||||
FUNC(xpmGetRGBfromName,int, (char *name, int *r, int *g, int *b));
|
FUNC(xpmGetRGBfromName,int, (char *name, int *r, int *g, int *b));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef AMIGA
|
||||||
FUNC(xpm_xynormalizeimagebits, void, (register unsigned char *bp,
|
FUNC(xpm_xynormalizeimagebits, void, (register unsigned char *bp,
|
||||||
register XImage *img));
|
register XImage *img));
|
||||||
FUNC(xpm_znormalizeimagebits, void, (register unsigned char *bp,
|
FUNC(xpm_znormalizeimagebits, void, (register unsigned char *bp,
|
||||||
@@ -259,46 +315,29 @@ FUNC(xpm_znormalizeimagebits, void, (register unsigned char *bp,
|
|||||||
#define ZINDEX8(x, y, img) ((y) * img->bytes_per_line) + (x)
|
#define ZINDEX8(x, y, img) ((y) * img->bytes_per_line) + (x)
|
||||||
|
|
||||||
#define ZINDEX1(x, y, img) ((y) * img->bytes_per_line) + ((x) >> 3)
|
#define ZINDEX1(x, y, img) ((y) * img->bytes_per_line) + ((x) >> 3)
|
||||||
|
#endif /* not AMIGA */
|
||||||
|
|
||||||
#if __STDC__
|
#ifdef __STDC__
|
||||||
#define Const const
|
#define Const const
|
||||||
#else
|
#else
|
||||||
#define Const /**/
|
#define Const /**/
|
||||||
#endif
|
#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)(unsigned long)((*slot)->data))
|
|
||||||
#define USE_HASHTABLE (cpp > 2 && ncolors > 4)
|
|
||||||
|
|
||||||
#ifdef NEED_STRDUP
|
#ifdef NEED_STRDUP
|
||||||
FUNC(strdup, char *, (char *s1));
|
FUNC(xpmstrdup, char *, (char *s1));
|
||||||
|
#else
|
||||||
|
#undef xpmstrdup
|
||||||
|
#define xpmstrdup strdup
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NEED_STRCASECMP
|
#ifdef NEED_STRCASECMP
|
||||||
FUNC(strcasecmp, int, (char *s1, char *s2));
|
FUNC(xpmstrcasecmp, int, (char *s1, char *s2));
|
||||||
|
#else
|
||||||
|
#undef xpmstrcasecmp
|
||||||
|
#define xpmstrcasecmp strcasecmp
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FUNC(atoui, unsigned int, (char *p, unsigned int l, unsigned int *ui_return));
|
FUNC(xpmatoui, unsigned int,
|
||||||
|
(char *p, unsigned int l, unsigned int *ui_return));
|
||||||
|
|
||||||
#endif
|
#endif
|
Reference in New Issue
Block a user