Reindented.

This commit is contained in:
Roger E. Masse 1997-01-03 18:51:01 +00:00
parent 752300bbdf
commit 5b0eba3ced
1 changed files with 540 additions and 510 deletions

View File

@ -248,7 +248,8 @@ sizeofimage(self, args)
readheader(inf,&image);
fclose(inf);
if(image.imagic != IMAGIC) {
PyErr_SetString(ImgfileError, "bad magic number in image file");
PyErr_SetString(ImgfileError,
"bad magic number in image file");
return NULL;
}
return Py_BuildValue("(ii)", image.xsize, image.ysize);
@ -293,7 +294,8 @@ longimagedata(self, args)
rle = ISRLE(image.type);
bpp = BPP(image.type);
if(bpp != 1 ) {
PyErr_SetString(ImgfileError,"image must have 1 byte per pix chan");
PyErr_SetString(ImgfileError,
"image must have 1 byte per pix chan");
fclose(inf);
return NULL;
}
@ -344,10 +346,12 @@ longimagedata(self, args)
for(z=0; z<zsize; z++) {
lptr = base;
if (reverse_order)
lptr += (ysize - 1) * xsize * sizeof(unsigned long);
lptr += (ysize - 1) * xsize
* sizeof(unsigned long);
for(y=0; y<ysize; y++) {
if(cur != starttab[y+z*ysize]) {
fseek(inf,starttab[y+z*ysize],SEEK_SET);
fseek(inf,starttab[y+z*ysize],
SEEK_SET);
cur = starttab[y+z*ysize];
}
if(lengthtab[y+z*ysize]>rlebuflen) {
@ -360,26 +364,32 @@ longimagedata(self, args)
free(lengthtab);
return NULL;
}
fread(rledat,lengthtab[y+z*ysize],1,inf);
fread(rledat,lengthtab[y+z*ysize],
1,inf);
cur += lengthtab[y+z*ysize];
expandrow(lptr,rledat,3-z);
if (reverse_order)
lptr -= xsize * sizeof(unsigned long);
lptr -= xsize
* sizeof(unsigned long);
else
lptr += xsize * sizeof(unsigned long);
lptr += xsize
* sizeof(unsigned long);
}
}
} else {
lptr = base;
if (reverse_order)
lptr += (ysize - 1) * xsize * sizeof(unsigned long);
lptr += (ysize - 1) * xsize
* sizeof(unsigned long);
for(y=0; y<ysize; y++) {
for(z=0; z<zsize; z++) {
if(cur != starttab[y+z*ysize]) {
fseek(inf,starttab[y+z*ysize],SEEK_SET);
fseek(inf,starttab[y+z*ysize],
SEEK_SET);
cur = starttab[y+z*ysize];
}
fread(rledat,lengthtab[y+z*ysize],1,inf);
fread(rledat,lengthtab[y+z*ysize],
1,inf);
cur += lengthtab[y+z*ysize];
expandrow(lptr,rledat,3-z);
}
@ -414,7 +424,8 @@ longimagedata(self, args)
for(z=0; z<zsize; z++) {
lptr = base;
if (reverse_order)
lptr += (ysize - 1) * xsize * sizeof(unsigned long);
lptr += (ysize - 1) * xsize
* sizeof(unsigned long);
for(y=0; y<ysize; y++) {
fread(verdat,xsize,1,inf);
interleaverow(lptr,verdat,3-z,xsize);
@ -606,12 +617,15 @@ longstoimage(self, args)
for(z=0; z<zsize; z++) {
if(zsize == 1) {
lumrow(lptr,lumbuf,xsize);
len = compressrow(lumbuf,rlebuf,CHANOFFSET(z),xsize);
len = compressrow(lumbuf,rlebuf,CHANOFFSET(z),
xsize);
} else {
len = compressrow(lptr,rlebuf,CHANOFFSET(z),xsize);
len = compressrow(lptr,rlebuf,CHANOFFSET(z),
xsize);
}
if(len>rlebuflen) {
PyErr_SetString(ImgfileError,"rlebuf is too small - bad poop");
PyErr_SetString(ImgfileError,
"rlebuf is too small - bad poop");
free(starttab);
free(lengthtab);
free(rlebuf);
@ -655,7 +669,8 @@ int n;
{
lumptr += CHANOFFSET(0);
while(n--) {
*lumptr = ILUM(rgbptr[OFFSET_R],rgbptr[OFFSET_G],rgbptr[OFFSET_B]);
*lumptr = ILUM(rgbptr[OFFSET_R],rgbptr[OFFSET_G],
rgbptr[OFFSET_B]);
lumptr += 4;
rgbptr += 4;
}
@ -677,7 +692,8 @@ int z, cnt;
while(iptr<ibufend) {
sptr = iptr;
iptr += 8;
while((iptr<ibufend)&& ((iptr[-8]!=iptr[-4])||(iptr[-4]!=iptr[0])))
while((iptr<ibufend)&& ((iptr[-8]!=iptr[-4])
||(iptr[-4]!=iptr[0])))
iptr+=4;
iptr -= 8;
count = (iptr-sptr)/4;
@ -749,6 +765,20 @@ initrgbimg()
m = Py_InitModule("rgbimg", rgbimg_methods);
d = PyModule_GetDict(m);
ImgfileError = PyString_FromString("rgbimg.error");
if (ImgfileError == NULL || PyDict_SetItemString(d, "error", ImgfileError))
if (ImgfileError == NULL
|| PyDict_SetItemString(d, "error", ImgfileError))
Py_FatalError("can't define rgbimg.error");
}