diff options
author | Guido van Rossum <guido@python.org> | 1991-11-12 15:41:00 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1991-11-12 15:41:00 (GMT) |
commit | 6d0b5a7880fcec6295274b1e260b85c3403a0861 (patch) | |
tree | 87127c16cdb050295867f26546e3953d92405376 /Modules/cstubs | |
parent | 56a5afc7ea3f168056bf7db6d259b27147e4d295 (diff) | |
download | cpython-6d0b5a7880fcec6295274b1e260b85c3403a0861.zip cpython-6d0b5a7880fcec6295274b1e260b85c3403a0861.tar.gz cpython-6d0b5a7880fcec6295274b1e260b85c3403a0861.tar.bz2 |
Improved RGB --> grayscale conversion.
Changed error reporting somewhat.
Diffstat (limited to 'Modules/cstubs')
-rw-r--r-- | Modules/cstubs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Modules/cstubs b/Modules/cstubs index 139ab96..cf301f9 100644 --- a/Modules/cstubs +++ b/Modules/cstubs @@ -587,12 +587,15 @@ gl_lrectwrite(self, args) return NULL; if (!getiobjectarg(args, 5, 4, &s)) return NULL; +#if 0 +/* Don't check this, it breaks experiments with pixmode(PM_SIZE, ...) */ pixcount = (long)(x2+1-x1) * (long)(y2+1-y1); if (!is_stringobject(s) || getstringsize(s) != pixcount*sizeof(long)) { - fprintf(stderr, "string arg to lrectwrite has wrong size\n"); - err_badarg(); + err_setstr(RuntimeError, + "string arg to lrectwrite has wrong size"); return NULL; } +#endif lrectwrite( x1 , y1 , x2 , y2 , (unsigned long *) parray ); INCREF(None); return None; @@ -675,8 +678,8 @@ gl_packrect(self, args) packedcount = ((width+packfactor-1)/packfactor) * ((height+packfactor-1)/packfactor); if (getstringsize(unpacked) != pixcount*sizeof(long)) { - fprintf(stderr, "string arg to packrect has wrong size\n"); - err_badarg(); + err_setstr(RuntimeError, + "string arg to packrect has wrong size"); return NULL; } packed = newsizedstringobject((char *)NULL, packedcount); @@ -690,7 +693,7 @@ gl_packrect(self, args) r = pixel & 0xff; g = (pixel >> 8) & 0xff; b = (pixel >> 16) & 0xff; - *p++ = (r+g+b) / 3; + *p++ = (30*r+59*g+11*b) / 100; } } return packed; @@ -736,8 +739,8 @@ gl_unpackrect(self, args) packedcount = ((width+packfactor-1)/packfactor) * ((height+packfactor-1)/packfactor); if (getstringsize(packed) != packedcount) { - fprintf(stderr, "string arg to unpackrect has wrong size\n"); - err_badarg(); + err_setstr(RuntimeError, + "string arg to unpackrect has wrong size"); return NULL; } unpacked = newsizedstringobject((char *)NULL, pixcount*sizeof(long)); |