diff options
author | Sjoerd Mullender <sjoerd@acm.org> | 1993-12-24 14:51:14 (GMT) |
---|---|---|
committer | Sjoerd Mullender <sjoerd@acm.org> | 1993-12-24 14:51:14 (GMT) |
commit | 0d2d397bc5d2dffa75c350b20d332023bd4a5b98 (patch) | |
tree | 4b6e590212513af3eab2fe6761aa205b834cb7f5 | |
parent | 627b2d7cd731f54428cdcc71aba124500533a9ee (diff) | |
download | cpython-0d2d397bc5d2dffa75c350b20d332023bd4a5b98.zip cpython-0d2d397bc5d2dffa75c350b20d332023bd4a5b98.tar.gz cpython-0d2d397bc5d2dffa75c350b20d332023bd4a5b98.tar.bz2 |
Added function ttob.
-rw-r--r-- | Modules/rgbimgmodule.c | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/Modules/rgbimgmodule.c b/Modules/rgbimgmodule.c index 4a983ef..86ee71c 100644 --- a/Modules/rgbimgmodule.c +++ b/Modules/rgbimgmodule.c @@ -96,6 +96,8 @@ static lumrow PROTO((unsigned char *, unsigned char *, int)); static object *ImgfileError; +static int reverse_order; + #ifdef ADD_TAGS /* * addlongimgtag - @@ -339,6 +341,8 @@ longimagedata(self, args) if(badorder) { for(z=0; z<zsize; z++) { lptr = base; + if (reverse_order) + 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); @@ -356,11 +360,16 @@ longimagedata(self, args) fread(rledat,lengthtab[y+z*ysize],1,inf); cur += lengthtab[y+z*ysize]; expandrow(lptr,rledat,3-z); - lptr += xsize * sizeof(unsigned long); + 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); for(y=0; y<ysize; y++) { for(z=0; z<zsize; z++) { if(cur != starttab[y+z*ysize]) { @@ -371,7 +380,10 @@ longimagedata(self, args) cur += lengthtab[y+z*ysize]; expandrow(lptr,rledat,3-z); } - lptr += xsize * sizeof(unsigned long); + if (reverse_order) + lptr -= xsize * sizeof(unsigned long); + else + lptr += xsize * sizeof(unsigned long); } } if(zsize == 3) @@ -398,10 +410,15 @@ longimagedata(self, args) fseek(inf,512,SEEK_SET); for(z=0; z<zsize; z++) { lptr = base; + if (reverse_order) + lptr += (ysize - 1) * xsize * sizeof(unsigned long); for(y=0; y<ysize; y++) { fread(verdat,xsize,1,inf); interleaverow(lptr,verdat,3-z,xsize); - lptr += xsize * sizeof(unsigned long); + if (reverse_order) + lptr -= xsize * sizeof(unsigned long); + else + lptr += xsize * sizeof(unsigned long); } } if(zsize == 3) @@ -579,6 +596,8 @@ longstoimage(self, args) goodwrite *= writeheader(outf,&image); fseek(outf,512+2*tablen,SEEK_SET); pos = 512+2*tablen; + if (reverse_order) + lptr += (ysize - 1) * xsize * sizeof(unsigned long); for(y=0; y<ysize; y++) { for(z=0; z<zsize; z++) { if(zsize == 1) { @@ -601,7 +620,10 @@ longstoimage(self, args) lengthtab[y+z*ysize] = len; pos += len; } - lptr += xsize * sizeof(unsigned long); + if (reverse_order) + lptr -= xsize * sizeof(unsigned long); + else + lptr += xsize * sizeof(unsigned long); } fseek(outf,512,SEEK_SET); @@ -694,10 +716,25 @@ int z, cnt; return optr - (unsigned char *)rlebuf; } +static object * +ttob(self, args) + object *self; + object *args; +{ + int order, oldorder; + + if (!getargs(args, "d", &order)) + return NULL; + oldorder = reverse_order; + reverse_order = order; + return newintobject(oldorder); +} + static struct methodlist rgbimg_methods[] = { {"sizeofimage", sizeofimage}, {"longimagedata", longimagedata}, {"longstoimage", longstoimage}, + {"ttob", ttob}, {NULL, NULL} /* sentinel */ }; |