1993-12-21 17:06:12 +00:00
|
|
|
/*
|
|
|
|
* fastimg -
|
|
|
|
* Faster reading and writing of image files.
|
|
|
|
*
|
|
|
|
* This code should work on machines with any byte order.
|
|
|
|
*
|
|
|
|
* Could someone make this run real fast using multiple processors
|
|
|
|
* or how about using memory mapped files to speed it up?
|
|
|
|
*
|
|
|
|
* Paul Haeberli - 1991
|
|
|
|
*
|
|
|
|
* Changed to return sizes.
|
|
|
|
* Sjoerd Mullender - 1993
|
|
|
|
* Changed to incorporate into Python.
|
|
|
|
* Sjoerd Mullender - 1993
|
|
|
|
*/
|
1996-12-11 21:33:16 +00:00
|
|
|
#include "Python.h"
|
|
|
|
|
1994-08-01 11:34:53 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
1993-12-21 17:06:12 +00:00
|
|
|
#include <unistd.h>
|
1994-08-01 11:34:53 +00:00
|
|
|
#endif
|
1993-12-24 10:05:51 +00:00
|
|
|
#include <string.h>
|
1993-12-21 17:06:12 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* from image.h
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
typedef struct {
|
1997-01-03 18:51:01 +00:00
|
|
|
unsigned short imagic; /* stuff saved on disk . . */
|
|
|
|
unsigned short type;
|
|
|
|
unsigned short dim;
|
|
|
|
unsigned short xsize;
|
|
|
|
unsigned short ysize;
|
|
|
|
unsigned short zsize;
|
|
|
|
unsigned long min;
|
|
|
|
unsigned long max;
|
|
|
|
unsigned long wastebytes;
|
|
|
|
char name[80];
|
|
|
|
unsigned long colormap;
|
|
|
|
|
|
|
|
long file; /* stuff used in core only */
|
|
|
|
unsigned short flags;
|
|
|
|
short dorev;
|
|
|
|
short x;
|
|
|
|
short y;
|
|
|
|
short z;
|
|
|
|
short cnt;
|
|
|
|
unsigned short *ptr;
|
|
|
|
unsigned short *base;
|
|
|
|
unsigned short *tmpbuf;
|
|
|
|
unsigned long offset;
|
|
|
|
unsigned long rleend; /* for rle images */
|
|
|
|
unsigned long *rowstart; /* for rle images */
|
|
|
|
long *rowsize; /* for rle images */
|
1993-12-21 17:06:12 +00:00
|
|
|
} IMAGE;
|
|
|
|
|
|
|
|
#define IMAGIC 0732
|
|
|
|
|
|
|
|
#define TYPEMASK 0xff00
|
|
|
|
#define BPPMASK 0x00ff
|
|
|
|
#define ITYPE_VERBATIM 0x0000
|
|
|
|
#define ITYPE_RLE 0x0100
|
|
|
|
#define ISRLE(type) (((type) & 0xff00) == ITYPE_RLE)
|
|
|
|
#define ISVERBATIM(type) (((type) & 0xff00) == ITYPE_VERBATIM)
|
|
|
|
#define BPP(type) ((type) & BPPMASK)
|
|
|
|
#define RLE(bpp) (ITYPE_RLE | (bpp))
|
|
|
|
#define VERBATIM(bpp) (ITYPE_VERBATIM | (bpp))
|
|
|
|
/*
|
|
|
|
* end of image.h stuff
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define RINTLUM (79)
|
|
|
|
#define GINTLUM (156)
|
|
|
|
#define BINTLUM (21)
|
|
|
|
|
|
|
|
#define ILUM(r,g,b) ((int)(RINTLUM*(r)+GINTLUM*(g)+BINTLUM*(b))>>8)
|
|
|
|
|
|
|
|
#define OFFSET_R 3 /* this is byte order dependent */
|
|
|
|
#define OFFSET_G 2
|
|
|
|
#define OFFSET_B 1
|
|
|
|
#define OFFSET_A 0
|
|
|
|
|
|
|
|
#define CHANOFFSET(z) (3-(z)) /* this is byte order dependent */
|
|
|
|
|
1996-12-11 21:33:16 +00:00
|
|
|
static void expandrow Py_PROTO((unsigned char *, unsigned char *, int));
|
|
|
|
static void setalpha Py_PROTO((unsigned char *, int));
|
|
|
|
static void copybw Py_PROTO((long *, int));
|
|
|
|
static void interleaverow Py_PROTO((unsigned char*, unsigned char*, int, int));
|
|
|
|
static int compressrow Py_PROTO((unsigned char *, unsigned char *, int, int));
|
|
|
|
static void lumrow Py_PROTO((unsigned char *, unsigned char *, int));
|
1993-12-21 17:06:12 +00:00
|
|
|
|
|
|
|
#ifdef ADD_TAGS
|
|
|
|
#define TAGLEN (5)
|
|
|
|
#else
|
|
|
|
#define TAGLEN (0)
|
|
|
|
#endif
|
|
|
|
|
1996-12-11 21:33:16 +00:00
|
|
|
static PyObject *ImgfileError;
|
1993-12-21 17:06:12 +00:00
|
|
|
|
1993-12-24 14:51:14 +00:00
|
|
|
static int reverse_order;
|
|
|
|
|
1993-12-21 17:06:12 +00:00
|
|
|
#ifdef ADD_TAGS
|
|
|
|
/*
|
|
|
|
* addlongimgtag -
|
|
|
|
* this is used to extract image data from core dumps.
|
|
|
|
*
|
|
|
|
*/
|
1997-01-09 22:29:12 +00:00
|
|
|
static void
|
|
|
|
addlongimgtag(dptr, xsize, ysize)
|
1997-01-03 18:51:01 +00:00
|
|
|
unsigned long *dptr;
|
1997-01-09 22:29:12 +00:00
|
|
|
int xsize, ysize;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-09 22:29:12 +00:00
|
|
|
dptr = dptr + (xsize * ysize);
|
1997-01-03 18:51:01 +00:00
|
|
|
dptr[0] = 0x12345678;
|
|
|
|
dptr[1] = 0x59493333;
|
|
|
|
dptr[2] = 0x69434222;
|
|
|
|
dptr[3] = xsize;
|
|
|
|
dptr[4] = ysize;
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* byte order independent read/write of shorts and longs.
|
|
|
|
*
|
|
|
|
*/
|
1997-01-09 22:29:12 +00:00
|
|
|
static unsigned short
|
|
|
|
getshort(inf)
|
1997-01-03 18:51:01 +00:00
|
|
|
FILE *inf;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-03 18:51:01 +00:00
|
|
|
unsigned char buf[2];
|
1993-12-21 17:06:12 +00:00
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
fread(buf, 2, 1, inf);
|
|
|
|
return (buf[0] << 8) + (buf[1] << 0);
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
static unsigned long
|
|
|
|
getlong(inf)
|
1997-01-03 18:51:01 +00:00
|
|
|
FILE *inf;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-03 18:51:01 +00:00
|
|
|
unsigned char buf[4];
|
1993-12-21 17:06:12 +00:00
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
fread(buf, 4, 1, inf);
|
|
|
|
return (buf[0] << 24) + (buf[1] << 16) + (buf[2] << 8) + (buf[3] << 0);
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
static void
|
|
|
|
putshort(outf, val)
|
1997-01-03 18:51:01 +00:00
|
|
|
FILE *outf;
|
1997-01-09 22:29:12 +00:00
|
|
|
unsigned short val;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-03 18:51:01 +00:00
|
|
|
unsigned char buf[2];
|
1993-12-21 17:06:12 +00:00
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
buf[0] = (val >> 8);
|
|
|
|
buf[1] = (val >> 0);
|
|
|
|
fwrite(buf, 2, 1, outf);
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
static int
|
|
|
|
putlong(outf, val)
|
1997-01-03 18:51:01 +00:00
|
|
|
FILE *outf;
|
1997-01-09 22:29:12 +00:00
|
|
|
unsigned long val;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-03 18:51:01 +00:00
|
|
|
unsigned char buf[4];
|
1993-12-21 17:06:12 +00:00
|
|
|
|
1997-04-11 20:44:04 +00:00
|
|
|
buf[0] = (unsigned char) (val >> 24);
|
|
|
|
buf[1] = (unsigned char) (val >> 16);
|
|
|
|
buf[2] = (unsigned char) (val >> 8);
|
|
|
|
buf[3] = (unsigned char) (val >> 0);
|
1997-01-09 22:29:12 +00:00
|
|
|
return fwrite(buf, 4, 1, outf);
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
static void
|
|
|
|
readheader(inf, image)
|
1997-01-03 18:51:01 +00:00
|
|
|
FILE *inf;
|
1997-01-09 22:29:12 +00:00
|
|
|
IMAGE *image;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-09 22:29:12 +00:00
|
|
|
memset(image ,0, sizeof(IMAGE));
|
1997-01-03 18:51:01 +00:00
|
|
|
image->imagic = getshort(inf);
|
1997-01-09 22:29:12 +00:00
|
|
|
image->type = getshort(inf);
|
|
|
|
image->dim = getshort(inf);
|
|
|
|
image->xsize = getshort(inf);
|
|
|
|
image->ysize = getshort(inf);
|
|
|
|
image->zsize = getshort(inf);
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
static int
|
|
|
|
writeheader(outf, image)
|
1997-01-03 18:51:01 +00:00
|
|
|
FILE *outf;
|
1997-01-09 22:29:12 +00:00
|
|
|
IMAGE *image;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-03 18:51:01 +00:00
|
|
|
IMAGE t;
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
memset(&t, 0, sizeof(IMAGE));
|
|
|
|
fwrite(&t, sizeof(IMAGE), 1, outf);
|
|
|
|
fseek(outf, 0, SEEK_SET);
|
|
|
|
putshort(outf, image->imagic);
|
|
|
|
putshort(outf, image->type);
|
|
|
|
putshort(outf, image->dim);
|
|
|
|
putshort(outf, image->xsize);
|
|
|
|
putshort(outf, image->ysize);
|
|
|
|
putshort(outf, image->zsize);
|
|
|
|
putlong(outf, image->min);
|
|
|
|
putlong(outf, image->max);
|
|
|
|
putlong(outf, 0);
|
|
|
|
return fwrite("no name", 8, 1, outf);
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
static int
|
|
|
|
writetab(outf, tab, len)
|
1997-01-03 18:51:01 +00:00
|
|
|
FILE *outf;
|
1997-01-09 22:29:12 +00:00
|
|
|
/*unsigned*/ long *tab;
|
|
|
|
int len;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-03 18:51:01 +00:00
|
|
|
int r = 0;
|
1993-12-21 17:06:12 +00:00
|
|
|
|
1997-01-03 18:51:01 +00:00
|
|
|
while(len) {
|
1997-01-09 22:29:12 +00:00
|
|
|
r = putlong(outf, *tab++);
|
1997-05-22 20:24:07 +00:00
|
|
|
len--;
|
1997-01-03 18:51:01 +00:00
|
|
|
}
|
|
|
|
return r;
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
static void
|
|
|
|
readtab(inf, tab, len)
|
1997-01-03 18:51:01 +00:00
|
|
|
FILE *inf;
|
1997-01-09 22:29:12 +00:00
|
|
|
/*unsigned*/ long *tab;
|
|
|
|
int len;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-03 18:51:01 +00:00
|
|
|
while(len) {
|
|
|
|
*tab++ = getlong(inf);
|
1997-05-22 20:24:07 +00:00
|
|
|
len--;
|
1997-01-03 18:51:01 +00:00
|
|
|
}
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sizeofimage -
|
|
|
|
* return the xsize and ysize of an iris image file.
|
|
|
|
*
|
|
|
|
*/
|
1996-12-11 21:33:16 +00:00
|
|
|
static PyObject *
|
1993-12-21 17:06:12 +00:00
|
|
|
sizeofimage(self, args)
|
1997-01-03 18:51:01 +00:00
|
|
|
PyObject *self, *args;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-03 18:51:01 +00:00
|
|
|
char *name;
|
|
|
|
IMAGE image;
|
|
|
|
FILE *inf;
|
|
|
|
|
|
|
|
if (!PyArg_Parse(args, "s", &name))
|
|
|
|
return NULL;
|
|
|
|
|
1997-04-11 19:12:20 +00:00
|
|
|
inf = fopen(name, "rb");
|
1997-01-09 22:29:12 +00:00
|
|
|
if (!inf) {
|
1997-01-03 18:51:01 +00:00
|
|
|
PyErr_SetString(ImgfileError, "can't open image file");
|
|
|
|
return NULL;
|
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
readheader(inf, &image);
|
1997-01-03 18:51:01 +00:00
|
|
|
fclose(inf);
|
1997-01-09 22:29:12 +00:00
|
|
|
if (image.imagic != IMAGIC) {
|
1997-01-03 18:51:01 +00:00
|
|
|
PyErr_SetString(ImgfileError,
|
|
|
|
"bad magic number in image file");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return Py_BuildValue("(ii)", image.xsize, image.ysize);
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* longimagedata -
|
|
|
|
* read in a B/W RGB or RGBA iris image file and return a
|
|
|
|
* pointer to an array of longs.
|
|
|
|
*
|
|
|
|
*/
|
1996-12-11 21:33:16 +00:00
|
|
|
static PyObject *
|
1993-12-21 17:06:12 +00:00
|
|
|
longimagedata(self, args)
|
1997-01-03 18:51:01 +00:00
|
|
|
PyObject *self, *args;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-03 18:51:01 +00:00
|
|
|
char *name;
|
|
|
|
unsigned char *base, *lptr;
|
1997-01-09 22:29:12 +00:00
|
|
|
unsigned char *rledat = NULL, *verdat = NULL;
|
|
|
|
long *starttab = NULL, *lengthtab = NULL;
|
|
|
|
FILE *inf = NULL;
|
1997-01-03 18:51:01 +00:00
|
|
|
IMAGE image;
|
|
|
|
int y, z, tablen;
|
|
|
|
int xsize, ysize, zsize;
|
|
|
|
int bpp, rle, cur, badorder;
|
|
|
|
int rlebuflen;
|
1997-01-09 22:29:12 +00:00
|
|
|
PyObject *rv = NULL;
|
1997-01-03 18:51:01 +00:00
|
|
|
|
|
|
|
if (!PyArg_Parse(args, "s", &name))
|
|
|
|
return NULL;
|
1993-12-21 17:06:12 +00:00
|
|
|
|
1997-02-21 15:19:03 +00:00
|
|
|
inf = fopen(name,"rb");
|
1997-01-09 22:29:12 +00:00
|
|
|
if (!inf) {
|
|
|
|
PyErr_SetString(ImgfileError, "can't open image file");
|
1997-01-03 18:51:01 +00:00
|
|
|
return NULL;
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
1997-01-03 18:51:01 +00:00
|
|
|
readheader(inf,&image);
|
1997-01-09 22:29:12 +00:00
|
|
|
if (image.imagic != IMAGIC) {
|
|
|
|
PyErr_SetString(ImgfileError,
|
|
|
|
"bad magic number in image file");
|
|
|
|
goto finally;
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
1997-01-03 18:51:01 +00:00
|
|
|
rle = ISRLE(image.type);
|
|
|
|
bpp = BPP(image.type);
|
1997-01-09 22:29:12 +00:00
|
|
|
if (bpp != 1) {
|
1997-01-03 18:51:01 +00:00
|
|
|
PyErr_SetString(ImgfileError,
|
|
|
|
"image must have 1 byte per pix chan");
|
1997-01-09 22:29:12 +00:00
|
|
|
goto finally;
|
1997-01-03 18:51:01 +00:00
|
|
|
}
|
|
|
|
xsize = image.xsize;
|
|
|
|
ysize = image.ysize;
|
|
|
|
zsize = image.zsize;
|
1997-01-09 22:29:12 +00:00
|
|
|
if (rle) {
|
|
|
|
tablen = ysize * zsize * sizeof(long);
|
1997-01-03 18:51:01 +00:00
|
|
|
starttab = (long *)malloc(tablen);
|
|
|
|
lengthtab = (long *)malloc(tablen);
|
1997-04-11 20:44:04 +00:00
|
|
|
rlebuflen = (int) (1.05 * xsize +10);
|
1997-01-03 18:51:01 +00:00
|
|
|
rledat = (unsigned char *)malloc(rlebuflen);
|
1997-01-09 22:29:12 +00:00
|
|
|
if (!starttab || !lengthtab || !rledat) {
|
|
|
|
PyErr_NoMemory();
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
|
|
|
|
fseek(inf, 512, SEEK_SET);
|
1997-05-22 20:24:07 +00:00
|
|
|
readtab(inf, starttab, ysize*zsize);
|
|
|
|
readtab(inf, lengthtab, ysize*zsize);
|
1997-01-03 18:51:01 +00:00
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
/* check data order */
|
1997-01-03 18:51:01 +00:00
|
|
|
cur = 0;
|
|
|
|
badorder = 0;
|
1997-01-09 22:29:12 +00:00
|
|
|
for(y = 0; y < ysize; y++) {
|
|
|
|
for(z = 0; z < zsize; z++) {
|
|
|
|
if (starttab[y + z * ysize] < cur) {
|
1997-01-03 18:51:01 +00:00
|
|
|
badorder = 1;
|
|
|
|
break;
|
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
cur = starttab[y +z * ysize];
|
1997-01-03 18:51:01 +00:00
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
if (badorder)
|
1997-01-03 18:51:01 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
fseek(inf, 512 + 2 * tablen, SEEK_SET);
|
|
|
|
cur = 512 + 2 * tablen;
|
|
|
|
rv = PyString_FromStringAndSize((char *)NULL,
|
|
|
|
(xsize * ysize + TAGLEN) * sizeof(long));
|
|
|
|
if (rv == NULL)
|
|
|
|
goto finally;
|
|
|
|
|
1997-01-03 18:51:01 +00:00
|
|
|
base = (unsigned char *) PyString_AsString(rv);
|
|
|
|
#ifdef ADD_TAGS
|
|
|
|
addlongimgtag(base,xsize,ysize);
|
|
|
|
#endif
|
1997-01-09 22:29:12 +00:00
|
|
|
if (badorder) {
|
|
|
|
for (z = 0; z < zsize; z++) {
|
1997-01-03 18:51:01 +00:00
|
|
|
lptr = base;
|
|
|
|
if (reverse_order)
|
|
|
|
lptr += (ysize - 1) * xsize
|
|
|
|
* sizeof(unsigned long);
|
1997-01-09 22:29:12 +00:00
|
|
|
for (y = 0; y < ysize; y++) {
|
|
|
|
int idx = y + z * ysize;
|
|
|
|
if (cur != starttab[idx]) {
|
|
|
|
fseek(inf,starttab[idx],
|
1997-01-03 18:51:01 +00:00
|
|
|
SEEK_SET);
|
1997-01-09 22:29:12 +00:00
|
|
|
cur = starttab[idx];
|
1997-01-03 18:51:01 +00:00
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
if (lengthtab[idx] > rlebuflen) {
|
1997-01-03 18:51:01 +00:00
|
|
|
PyErr_SetString(ImgfileError,
|
1997-01-09 22:29:12 +00:00
|
|
|
"rlebuf is too small");
|
1997-01-03 18:51:01 +00:00
|
|
|
Py_DECREF(rv);
|
1997-01-09 22:29:12 +00:00
|
|
|
rv = NULL;
|
|
|
|
goto finally;
|
1997-01-03 18:51:01 +00:00
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
fread(rledat, lengthtab[idx], 1, inf);
|
|
|
|
cur += lengthtab[idx];
|
|
|
|
expandrow(lptr, rledat, 3-z);
|
1997-01-03 18:51:01 +00:00
|
|
|
if (reverse_order)
|
|
|
|
lptr -= xsize
|
|
|
|
* sizeof(unsigned long);
|
|
|
|
else
|
|
|
|
lptr += xsize
|
|
|
|
* sizeof(unsigned long);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
lptr = base;
|
|
|
|
if (reverse_order)
|
|
|
|
lptr += (ysize - 1) * xsize
|
|
|
|
* sizeof(unsigned long);
|
1997-01-09 22:29:12 +00:00
|
|
|
for (y = 0; y < ysize; y++) {
|
|
|
|
for(z = 0; z < zsize; z++) {
|
|
|
|
int idx = y + z * ysize;
|
|
|
|
if (cur != starttab[idx]) {
|
|
|
|
fseek(inf, starttab[idx],
|
1997-01-03 18:51:01 +00:00
|
|
|
SEEK_SET);
|
1997-01-09 22:29:12 +00:00
|
|
|
cur = starttab[idx];
|
1997-01-03 18:51:01 +00:00
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
fread(rledat, lengthtab[idx], 1, inf);
|
|
|
|
cur += lengthtab[idx];
|
|
|
|
expandrow(lptr, rledat, 3-z);
|
1997-01-03 18:51:01 +00:00
|
|
|
}
|
|
|
|
if (reverse_order)
|
|
|
|
lptr -= xsize * sizeof(unsigned long);
|
|
|
|
else
|
|
|
|
lptr += xsize * sizeof(unsigned long);
|
|
|
|
}
|
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
if (zsize == 3)
|
|
|
|
setalpha(base, xsize * ysize);
|
|
|
|
else if (zsize < 3)
|
|
|
|
copybw((long *) base, xsize * ysize);
|
|
|
|
}
|
|
|
|
else {
|
1997-01-03 18:51:01 +00:00
|
|
|
rv = PyString_FromStringAndSize((char *) 0,
|
|
|
|
(xsize*ysize+TAGLEN)*sizeof(long));
|
1997-01-09 22:29:12 +00:00
|
|
|
if (rv == NULL)
|
|
|
|
goto finally;
|
|
|
|
|
1997-01-03 18:51:01 +00:00
|
|
|
base = (unsigned char *) PyString_AsString(rv);
|
1993-12-21 17:06:12 +00:00
|
|
|
#ifdef ADD_TAGS
|
1997-01-09 22:29:12 +00:00
|
|
|
addlongimgtag(base, xsize, ysize);
|
1993-12-21 17:06:12 +00:00
|
|
|
#endif
|
1997-01-03 18:51:01 +00:00
|
|
|
verdat = (unsigned char *)malloc(xsize);
|
1997-01-09 22:29:12 +00:00
|
|
|
fseek(inf, 512, SEEK_SET);
|
|
|
|
for (z = 0; z < zsize; z++) {
|
1997-01-03 18:51:01 +00:00
|
|
|
lptr = base;
|
|
|
|
if (reverse_order)
|
|
|
|
lptr += (ysize - 1) * xsize
|
|
|
|
* sizeof(unsigned long);
|
1997-01-09 22:29:12 +00:00
|
|
|
for (y = 0; y < ysize; y++) {
|
|
|
|
fread(verdat, xsize, 1, inf);
|
|
|
|
interleaverow(lptr, verdat, 3-z, xsize);
|
1997-01-03 18:51:01 +00:00
|
|
|
if (reverse_order)
|
|
|
|
lptr -= xsize * sizeof(unsigned long);
|
|
|
|
else
|
|
|
|
lptr += xsize * sizeof(unsigned long);
|
|
|
|
}
|
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
if (zsize == 3)
|
|
|
|
setalpha(base, xsize * ysize);
|
|
|
|
else if (zsize < 3)
|
|
|
|
copybw((long *) base, xsize * ysize);
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
finally:
|
|
|
|
free(starttab);
|
|
|
|
free(lengthtab);
|
|
|
|
free(rledat);
|
|
|
|
free(verdat);
|
|
|
|
fclose(inf);
|
|
|
|
return rv;
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static utility functions for longimagedata */
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
static void
|
|
|
|
interleaverow(lptr, cptr, z, n)
|
1997-01-03 18:51:01 +00:00
|
|
|
unsigned char *lptr, *cptr;
|
1997-01-09 22:29:12 +00:00
|
|
|
int z, n;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-03 18:51:01 +00:00
|
|
|
lptr += z;
|
1997-01-09 22:29:12 +00:00
|
|
|
while (n--) {
|
1997-01-03 18:51:01 +00:00
|
|
|
*lptr = *cptr++;
|
|
|
|
lptr += 4;
|
|
|
|
}
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
static void
|
|
|
|
copybw(lptr, n)
|
1997-01-03 18:51:01 +00:00
|
|
|
long *lptr;
|
1997-01-09 22:29:12 +00:00
|
|
|
int n;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-09 22:29:12 +00:00
|
|
|
while (n >= 8) {
|
|
|
|
lptr[0] = 0xff000000 + (0x010101 * (lptr[0] & 0xff));
|
|
|
|
lptr[1] = 0xff000000 + (0x010101 * (lptr[1] & 0xff));
|
|
|
|
lptr[2] = 0xff000000 + (0x010101 * (lptr[2] & 0xff));
|
|
|
|
lptr[3] = 0xff000000 + (0x010101 * (lptr[3] & 0xff));
|
|
|
|
lptr[4] = 0xff000000 + (0x010101 * (lptr[4] & 0xff));
|
|
|
|
lptr[5] = 0xff000000 + (0x010101 * (lptr[5] & 0xff));
|
|
|
|
lptr[6] = 0xff000000 + (0x010101 * (lptr[6] & 0xff));
|
|
|
|
lptr[7] = 0xff000000 + (0x010101 * (lptr[7] & 0xff));
|
1997-01-03 18:51:01 +00:00
|
|
|
lptr += 8;
|
1997-01-09 22:29:12 +00:00
|
|
|
n -= 8;
|
1997-01-03 18:51:01 +00:00
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
while (n--) {
|
|
|
|
*lptr = 0xff000000 + (0x010101 * (*lptr&0xff));
|
1997-01-03 18:51:01 +00:00
|
|
|
lptr++;
|
|
|
|
}
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
static void
|
|
|
|
setalpha(lptr, n)
|
1997-01-03 18:51:01 +00:00
|
|
|
unsigned char *lptr;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-09 22:29:12 +00:00
|
|
|
while (n >= 8) {
|
|
|
|
lptr[0 * 4] = 0xff;
|
|
|
|
lptr[1 * 4] = 0xff;
|
|
|
|
lptr[2 * 4] = 0xff;
|
|
|
|
lptr[3 * 4] = 0xff;
|
|
|
|
lptr[4 * 4] = 0xff;
|
|
|
|
lptr[5 * 4] = 0xff;
|
|
|
|
lptr[6 * 4] = 0xff;
|
|
|
|
lptr[7 * 4] = 0xff;
|
|
|
|
lptr += 4 * 8;
|
1997-01-03 18:51:01 +00:00
|
|
|
n -= 8;
|
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
while (n--) {
|
1997-01-03 18:51:01 +00:00
|
|
|
*lptr = 0xff;
|
|
|
|
lptr += 4;
|
|
|
|
}
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
static void
|
|
|
|
expandrow(optr, iptr, z)
|
1997-01-03 18:51:01 +00:00
|
|
|
unsigned char *optr, *iptr;
|
1997-01-09 22:29:12 +00:00
|
|
|
int z;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-03 18:51:01 +00:00
|
|
|
unsigned char pixel, count;
|
|
|
|
|
|
|
|
optr += z;
|
1997-01-09 22:29:12 +00:00
|
|
|
while (1) {
|
1997-01-03 18:51:01 +00:00
|
|
|
pixel = *iptr++;
|
1997-01-09 22:29:12 +00:00
|
|
|
if (!(count = (pixel & 0x7f)))
|
1997-01-03 18:51:01 +00:00
|
|
|
return;
|
1997-01-09 22:29:12 +00:00
|
|
|
if (pixel & 0x80) {
|
|
|
|
while (count >= 8) {
|
|
|
|
optr[0 * 4] = iptr[0];
|
|
|
|
optr[1 * 4] = iptr[1];
|
|
|
|
optr[2 * 4] = iptr[2];
|
|
|
|
optr[3 * 4] = iptr[3];
|
|
|
|
optr[4 * 4] = iptr[4];
|
|
|
|
optr[5 * 4] = iptr[5];
|
|
|
|
optr[6 * 4] = iptr[6];
|
|
|
|
optr[7 * 4] = iptr[7];
|
|
|
|
optr += 8 * 4;
|
1997-01-03 18:51:01 +00:00
|
|
|
iptr += 8;
|
|
|
|
count -= 8;
|
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
while (count--) {
|
1997-01-03 18:51:01 +00:00
|
|
|
*optr = *iptr++;
|
1997-01-09 22:29:12 +00:00
|
|
|
optr += 4;
|
1997-01-03 18:51:01 +00:00
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
}
|
|
|
|
else {
|
1997-01-03 18:51:01 +00:00
|
|
|
pixel = *iptr++;
|
1997-01-09 22:29:12 +00:00
|
|
|
while (count >= 8) {
|
|
|
|
optr[0 * 4] = pixel;
|
|
|
|
optr[1 * 4] = pixel;
|
|
|
|
optr[2 * 4] = pixel;
|
|
|
|
optr[3 * 4] = pixel;
|
|
|
|
optr[4 * 4] = pixel;
|
|
|
|
optr[5 * 4] = pixel;
|
|
|
|
optr[6 * 4] = pixel;
|
|
|
|
optr[7 * 4] = pixel;
|
|
|
|
optr += 8 * 4;
|
1997-01-03 18:51:01 +00:00
|
|
|
count -= 8;
|
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
while (count--) {
|
1997-01-03 18:51:01 +00:00
|
|
|
*optr = pixel;
|
1997-01-09 22:29:12 +00:00
|
|
|
optr += 4;
|
1997-01-03 18:51:01 +00:00
|
|
|
}
|
|
|
|
}
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* longstoimage -
|
|
|
|
* copy an array of longs to an iris image file. Each long
|
|
|
|
* represents one pixel. xsize and ysize specify the dimensions of
|
|
|
|
* the pixel array. zsize specifies what kind of image file to
|
|
|
|
* write out. if zsize is 1, the luminance of the pixels are
|
|
|
|
* calculated, and a sinlge channel black and white image is saved.
|
|
|
|
* If zsize is 3, an RGB image file is saved. If zsize is 4, an
|
|
|
|
* RGBA image file is saved.
|
|
|
|
*
|
|
|
|
*/
|
1996-12-11 21:33:16 +00:00
|
|
|
static PyObject *
|
1993-12-21 17:06:12 +00:00
|
|
|
longstoimage(self, args)
|
1997-01-03 18:51:01 +00:00
|
|
|
PyObject *self, *args;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-03 18:51:01 +00:00
|
|
|
unsigned char *lptr;
|
|
|
|
char *name;
|
|
|
|
int xsize, ysize, zsize;
|
1997-01-09 22:29:12 +00:00
|
|
|
FILE *outf = NULL;
|
1997-01-03 18:51:01 +00:00
|
|
|
IMAGE image;
|
|
|
|
int tablen, y, z, pos, len;
|
1997-01-09 22:29:12 +00:00
|
|
|
long *starttab = NULL, *lengthtab = NULL;
|
|
|
|
unsigned char *rlebuf = NULL;
|
|
|
|
unsigned char *lumbuf = NULL;
|
1997-01-03 18:51:01 +00:00
|
|
|
int rlebuflen, goodwrite;
|
1997-01-09 22:29:12 +00:00
|
|
|
PyObject *retval = NULL;
|
1997-01-03 18:51:01 +00:00
|
|
|
|
|
|
|
if (!PyArg_Parse(args, "(s#iiis)", &lptr, &len, &xsize, &ysize, &zsize,
|
|
|
|
&name))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
goodwrite = 1;
|
1997-02-21 15:19:03 +00:00
|
|
|
outf = fopen(name, "wb");
|
1997-01-09 22:29:12 +00:00
|
|
|
if (!outf) {
|
|
|
|
PyErr_SetString(ImgfileError, "can't open output file");
|
1993-12-21 17:06:12 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
tablen = ysize * zsize * sizeof(long);
|
1997-01-03 18:51:01 +00:00
|
|
|
|
|
|
|
starttab = (long *)malloc(tablen);
|
|
|
|
lengthtab = (long *)malloc(tablen);
|
1997-04-11 20:44:04 +00:00
|
|
|
rlebuflen = (int) (1.05 * xsize + 10);
|
1997-01-03 18:51:01 +00:00
|
|
|
rlebuf = (unsigned char *)malloc(rlebuflen);
|
1997-01-09 22:29:12 +00:00
|
|
|
lumbuf = (unsigned char *)malloc(xsize * sizeof(long));
|
|
|
|
if (!starttab || !lengthtab || !rlebuf || !lumbuf) {
|
|
|
|
PyErr_NoMemory();
|
|
|
|
goto finally;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(&image, 0, sizeof(IMAGE));
|
1997-01-03 18:51:01 +00:00
|
|
|
image.imagic = IMAGIC;
|
|
|
|
image.type = RLE(1);
|
1997-01-09 22:29:12 +00:00
|
|
|
if (zsize>1)
|
1997-01-03 18:51:01 +00:00
|
|
|
image.dim = 3;
|
1993-12-24 14:51:14 +00:00
|
|
|
else
|
1997-01-03 18:51:01 +00:00
|
|
|
image.dim = 2;
|
|
|
|
image.xsize = xsize;
|
|
|
|
image.ysize = ysize;
|
|
|
|
image.zsize = zsize;
|
|
|
|
image.min = 0;
|
|
|
|
image.max = 255;
|
1997-01-09 22:29:12 +00:00
|
|
|
goodwrite *= writeheader(outf, &image);
|
|
|
|
pos = 512 + 2 * tablen;
|
|
|
|
fseek(outf, pos, SEEK_SET);
|
1997-01-03 18:51:01 +00:00
|
|
|
if (reverse_order)
|
|
|
|
lptr += (ysize - 1) * xsize * sizeof(unsigned long);
|
1997-01-09 22:29:12 +00:00
|
|
|
for (y = 0; y < ysize; y++) {
|
|
|
|
for (z = 0; z < zsize; z++) {
|
|
|
|
if (zsize == 1) {
|
|
|
|
lumrow(lptr, lumbuf, xsize);
|
|
|
|
len = compressrow(lumbuf, rlebuf,
|
|
|
|
CHANOFFSET(z), xsize);
|
1997-01-03 18:51:01 +00:00
|
|
|
} else {
|
1997-01-09 22:29:12 +00:00
|
|
|
len = compressrow(lptr, rlebuf,
|
|
|
|
CHANOFFSET(z), xsize);
|
1997-01-03 18:51:01 +00:00
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
if(len > rlebuflen) {
|
1997-01-03 18:51:01 +00:00
|
|
|
PyErr_SetString(ImgfileError,
|
1997-01-09 22:29:12 +00:00
|
|
|
"rlebuf is too small");
|
|
|
|
goto finally;
|
1997-01-03 18:51:01 +00:00
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
goodwrite *= fwrite(rlebuf, len, 1, outf);
|
|
|
|
starttab[y + z * ysize] = pos;
|
|
|
|
lengthtab[y + z * ysize] = len;
|
1997-01-03 18:51:01 +00:00
|
|
|
pos += len;
|
|
|
|
}
|
|
|
|
if (reverse_order)
|
|
|
|
lptr -= xsize * sizeof(unsigned long);
|
|
|
|
else
|
|
|
|
lptr += xsize * sizeof(unsigned long);
|
|
|
|
}
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
fseek(outf, 512, SEEK_SET);
|
1997-05-22 20:24:07 +00:00
|
|
|
goodwrite *= writetab(outf, starttab, ysize*zsize);
|
|
|
|
goodwrite *= writetab(outf, lengthtab, ysize*zsize);
|
1997-01-09 22:29:12 +00:00
|
|
|
if (goodwrite) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
retval = Py_None;
|
|
|
|
} else
|
|
|
|
PyErr_SetString(ImgfileError, "not enough space for image");
|
|
|
|
|
|
|
|
finally:
|
|
|
|
fclose(outf);
|
1997-01-03 18:51:01 +00:00
|
|
|
free(starttab);
|
|
|
|
free(lengthtab);
|
|
|
|
free(rlebuf);
|
|
|
|
free(lumbuf);
|
1997-01-09 22:29:12 +00:00
|
|
|
return retval;
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* static utility functions for longstoimage */
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
static void
|
|
|
|
lumrow(rgbptr, lumptr, n)
|
1997-01-03 18:51:01 +00:00
|
|
|
unsigned char *rgbptr, *lumptr;
|
1997-01-09 22:29:12 +00:00
|
|
|
int n;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-03 18:51:01 +00:00
|
|
|
lumptr += CHANOFFSET(0);
|
1997-01-09 22:29:12 +00:00
|
|
|
while (n--) {
|
|
|
|
*lumptr = ILUM(rgbptr[OFFSET_R],
|
|
|
|
rgbptr[OFFSET_G],
|
1997-01-03 18:51:01 +00:00
|
|
|
rgbptr[OFFSET_B]);
|
|
|
|
lumptr += 4;
|
|
|
|
rgbptr += 4;
|
|
|
|
}
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
static int
|
|
|
|
compressrow(lbuf, rlebuf, z, cnt)
|
1997-01-03 18:51:01 +00:00
|
|
|
unsigned char *lbuf, *rlebuf;
|
1997-01-09 22:29:12 +00:00
|
|
|
int z, cnt;
|
1993-12-21 17:06:12 +00:00
|
|
|
{
|
1997-01-03 18:51:01 +00:00
|
|
|
unsigned char *iptr, *ibufend, *sptr, *optr;
|
|
|
|
short todo, cc;
|
|
|
|
long count;
|
|
|
|
|
|
|
|
lbuf += z;
|
|
|
|
iptr = lbuf;
|
1997-01-09 22:29:12 +00:00
|
|
|
ibufend = iptr + cnt * 4;
|
1997-01-03 18:51:01 +00:00
|
|
|
optr = rlebuf;
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
while(iptr < ibufend) {
|
1997-01-03 18:51:01 +00:00
|
|
|
sptr = iptr;
|
|
|
|
iptr += 8;
|
1997-01-09 22:29:12 +00:00
|
|
|
while ((iptr<ibufend) &&
|
|
|
|
((iptr[-8]!=iptr[-4]) ||(iptr[-4]!=iptr[0])))
|
|
|
|
{
|
|
|
|
iptr += 4;
|
|
|
|
}
|
1997-01-03 18:51:01 +00:00
|
|
|
iptr -= 8;
|
1997-01-09 22:29:12 +00:00
|
|
|
count = (iptr - sptr) / 4;
|
|
|
|
while (count) {
|
1997-04-11 20:44:04 +00:00
|
|
|
todo = count > 126 ? 126 : (short)count;
|
1997-01-03 18:51:01 +00:00
|
|
|
count -= todo;
|
1997-01-09 22:29:12 +00:00
|
|
|
*optr++ = 0x80 | todo;
|
|
|
|
while (todo > 8) {
|
|
|
|
optr[0] = sptr[0 * 4];
|
|
|
|
optr[1] = sptr[1 * 4];
|
|
|
|
optr[2] = sptr[2 * 4];
|
|
|
|
optr[3] = sptr[3 * 4];
|
|
|
|
optr[4] = sptr[4 * 4];
|
|
|
|
optr[5] = sptr[5 * 4];
|
|
|
|
optr[6] = sptr[6 * 4];
|
|
|
|
optr[7] = sptr[7 * 4];
|
1997-01-03 18:51:01 +00:00
|
|
|
optr += 8;
|
1997-01-09 22:29:12 +00:00
|
|
|
sptr += 8 * 4;
|
1997-01-03 18:51:01 +00:00
|
|
|
todo -= 8;
|
|
|
|
}
|
1997-01-09 22:29:12 +00:00
|
|
|
while (todo--) {
|
1997-01-03 18:51:01 +00:00
|
|
|
*optr++ = *sptr;
|
|
|
|
sptr += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sptr = iptr;
|
|
|
|
cc = *iptr;
|
|
|
|
iptr += 4;
|
1997-01-09 22:29:12 +00:00
|
|
|
while ((iptr < ibufend) && (*iptr == cc))
|
1997-01-03 18:51:01 +00:00
|
|
|
iptr += 4;
|
1997-01-09 22:29:12 +00:00
|
|
|
count = (iptr - sptr) / 4;
|
|
|
|
while (count) {
|
1997-04-11 20:44:04 +00:00
|
|
|
todo = count > 126 ? 126 : (short)count;
|
1997-01-03 18:51:01 +00:00
|
|
|
count -= todo;
|
1997-04-11 20:44:04 +00:00
|
|
|
*optr++ = (unsigned char) todo;
|
|
|
|
*optr++ = (unsigned char) cc;
|
1997-01-03 18:51:01 +00:00
|
|
|
}
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
1997-01-03 18:51:01 +00:00
|
|
|
*optr++ = 0;
|
|
|
|
return optr - (unsigned char *)rlebuf;
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|
|
|
|
|
1996-12-11 21:33:16 +00:00
|
|
|
static PyObject *
|
1993-12-24 14:51:14 +00:00
|
|
|
ttob(self, args)
|
1997-01-03 18:51:01 +00:00
|
|
|
PyObject *self;
|
1997-01-09 22:29:12 +00:00
|
|
|
PyObject *args;
|
1993-12-24 14:51:14 +00:00
|
|
|
{
|
1997-01-03 18:51:01 +00:00
|
|
|
int order, oldorder;
|
1993-12-24 14:51:14 +00:00
|
|
|
|
1997-01-03 18:51:01 +00:00
|
|
|
if (!PyArg_Parse(args, "i", &order))
|
|
|
|
return NULL;
|
|
|
|
oldorder = reverse_order;
|
|
|
|
reverse_order = order;
|
|
|
|
return PyInt_FromLong(oldorder);
|
1993-12-24 14:51:14 +00:00
|
|
|
}
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
static PyMethodDef
|
|
|
|
rgbimg_methods[] = {
|
|
|
|
{"sizeofimage", sizeofimage},
|
|
|
|
{"longimagedata", longimagedata},
|
|
|
|
{"longstoimage", longstoimage},
|
|
|
|
{"ttob", ttob},
|
|
|
|
{NULL, NULL} /* sentinel */
|
1993-12-21 17:06:12 +00:00
|
|
|
};
|
|
|
|
|
1997-01-09 22:29:12 +00:00
|
|
|
|
1993-12-21 17:06:12 +00:00
|
|
|
void
|
|
|
|
initrgbimg()
|
|
|
|
{
|
1997-01-03 18:51:01 +00:00
|
|
|
PyObject *m, *d;
|
|
|
|
m = Py_InitModule("rgbimg", rgbimg_methods);
|
|
|
|
d = PyModule_GetDict(m);
|
1997-10-01 04:29:29 +00:00
|
|
|
ImgfileError = PyErr_NewException("rgbimg.error", NULL, NULL);
|
|
|
|
if (ImgfileError != NULL)
|
1997-01-09 22:29:12 +00:00
|
|
|
PyDict_SetItemString(d, "error", ImgfileError);
|
1993-12-21 17:06:12 +00:00
|
|
|
}
|