[Python-3000-checkins] r55460 - in python/branches/p3yk: Doc/Makefile.deps Doc/lib/lib.tex Doc/lib/libimageop.tex Lib/test/regrtest.py Lib/test/test_imageop.py Misc/NEWS Modules/Setup.dist Modules/imageop.c README setup.py

brett.cannon python-3000-checkins at python.org
Sun May 20 09:32:06 CEST 2007


Author: brett.cannon
Date: Sun May 20 09:31:57 2007
New Revision: 55460

Removed:
   python/branches/p3yk/Doc/lib/libimageop.tex
   python/branches/p3yk/Lib/test/test_imageop.py
   python/branches/p3yk/Modules/imageop.c
Modified:
   python/branches/p3yk/Doc/Makefile.deps
   python/branches/p3yk/Doc/lib/lib.tex
   python/branches/p3yk/Lib/test/regrtest.py
   python/branches/p3yk/Misc/NEWS
   python/branches/p3yk/Modules/Setup.dist
   python/branches/p3yk/README
   python/branches/p3yk/setup.py
Log:
Remove the imageop module.  With imgfile already removed in Python 3.0 and
rgbimg gone in Python 2.6 the unit tests themselves were made worthless.  Plus
third-party libraries perform the same function much better.


Modified: python/branches/p3yk/Doc/Makefile.deps
==============================================================================
--- python/branches/p3yk/Doc/Makefile.deps	(original)
+++ python/branches/p3yk/Doc/Makefile.deps	Sun May 20 09:31:57 2007
@@ -197,7 +197,6 @@
 	lib/libbinascii.tex \
 	lib/libmm.tex \
 	lib/libaudioop.tex \
-	lib/libimageop.tex \
 	lib/libaifc.tex \
 	lib/librgbimg.tex \
 	lib/libossaudiodev.tex \

Modified: python/branches/p3yk/Doc/lib/lib.tex
==============================================================================
--- python/branches/p3yk/Doc/lib/lib.tex	(original)
+++ python/branches/p3yk/Doc/lib/lib.tex	Sun May 20 09:31:57 2007
@@ -317,7 +317,6 @@
 
 \input{libmm}                   % Multimedia Services
 \input{libaudioop}
-\input{libimageop}
 \input{libaifc}
 \input{libsunau}
 \input{libwave}

Deleted: /python/branches/p3yk/Doc/lib/libimageop.tex
==============================================================================
--- /python/branches/p3yk/Doc/lib/libimageop.tex	Sun May 20 09:31:57 2007
+++ (empty file)
@@ -1,100 +0,0 @@
-\section{\module{imageop} ---
-         Manipulate raw image data}
-
-\declaremodule{builtin}{imageop}
-\modulesynopsis{Manipulate raw image data.}
-
-
-The \module{imageop} module contains some useful operations on images.
-It operates on images consisting of 8 or 32 bit pixels stored in
-Python strings.  This is the same format as used by
-\function{gl.lrectwrite()} and the \refmodule{imgfile} module.
-
-The module defines the following variables and functions:
-
-\begin{excdesc}{error}
-This exception is raised on all errors, such as unknown number of bits
-per pixel, etc.
-\end{excdesc}
-
-
-\begin{funcdesc}{crop}{image, psize, width, height, x0, y0, x1, y1}
-Return the selected part of \var{image}, which should be
-\var{width} by \var{height} in size and consist of pixels of
-\var{psize} bytes. \var{x0}, \var{y0}, \var{x1} and \var{y1} are like
-the \function{gl.lrectread()} parameters, i.e.\ the boundary is
-included in the new image.  The new boundaries need not be inside the
-picture.  Pixels that fall outside the old image will have their value
-set to zero.  If \var{x0} is bigger than \var{x1} the new image is
-mirrored.  The same holds for the y coordinates.
-\end{funcdesc}
-
-\begin{funcdesc}{scale}{image, psize, width, height, newwidth, newheight}
-Return \var{image} scaled to size \var{newwidth} by \var{newheight}.
-No interpolation is done, scaling is done by simple-minded pixel
-duplication or removal.  Therefore, computer-generated images or
-dithered images will not look nice after scaling.
-\end{funcdesc}
-
-\begin{funcdesc}{tovideo}{image, psize, width, height}
-Run a vertical low-pass filter over an image.  It does so by computing
-each destination pixel as the average of two vertically-aligned source
-pixels.  The main use of this routine is to forestall excessive
-flicker if the image is displayed on a video device that uses
-interlacing, hence the name.
-\end{funcdesc}
-
-\begin{funcdesc}{grey2mono}{image, width, height, threshold}
-Convert a 8-bit deep greyscale image to a 1-bit deep image by
-thresholding all the pixels.  The resulting image is tightly packed and
-is probably only useful as an argument to \function{mono2grey()}.
-\end{funcdesc}
-
-\begin{funcdesc}{dither2mono}{image, width, height}
-Convert an 8-bit greyscale image to a 1-bit monochrome image using a
-(simple-minded) dithering algorithm.
-\end{funcdesc}
-
-\begin{funcdesc}{mono2grey}{image, width, height, p0, p1}
-Convert a 1-bit monochrome image to an 8 bit greyscale or color image.
-All pixels that are zero-valued on input get value \var{p0} on output
-and all one-value input pixels get value \var{p1} on output.  To
-convert a monochrome black-and-white image to greyscale pass the
-values \code{0} and \code{255} respectively.
-\end{funcdesc}
-
-\begin{funcdesc}{grey2grey4}{image, width, height}
-Convert an 8-bit greyscale image to a 4-bit greyscale image without
-dithering.
-\end{funcdesc}
-
-\begin{funcdesc}{grey2grey2}{image, width, height}
-Convert an 8-bit greyscale image to a 2-bit greyscale image without
-dithering.
-\end{funcdesc}
-
-\begin{funcdesc}{dither2grey2}{image, width, height}
-Convert an 8-bit greyscale image to a 2-bit greyscale image with
-dithering.  As for \function{dither2mono()}, the dithering algorithm
-is currently very simple.
-\end{funcdesc}
-
-\begin{funcdesc}{grey42grey}{image, width, height}
-Convert a 4-bit greyscale image to an 8-bit greyscale image.
-\end{funcdesc}
-
-\begin{funcdesc}{grey22grey}{image, width, height}
-Convert a 2-bit greyscale image to an 8-bit greyscale image.
-\end{funcdesc}
-
-\begin{datadesc}{backward_compatible}
-If set to 0, the functions in this module use a non-backward
-compatible way of representing multi-byte pixels on little-endian
-systems.  The SGI for which this module was originally written is a
-big-endian system, so setting this variable will have no effect.
-However, the code wasn't originally intended to run on anything else,
-so it made assumptions about byte order which are not universal.
-Setting this variable to 0 will cause the byte order to be reversed on
-little-endian systems, so that it then is the same as on big-endian
-systems.
-\end{datadesc}

Modified: python/branches/p3yk/Lib/test/regrtest.py
==============================================================================
--- python/branches/p3yk/Lib/test/regrtest.py	(original)
+++ python/branches/p3yk/Lib/test/regrtest.py	Sun May 20 09:31:57 2007
@@ -1229,10 +1229,6 @@
             if test_timeout.skip_expected:
                 self.expected.add('test_timeout')
 
-            if sys.maxint == 9223372036854775807:
-                self.expected.add('test_rgbimg')
-                self.expected.add('test_imageop')
-
             if not sys.platform in ("mac", "darwin"):
                 MAC_ONLY = ["test_macostools", "test_macfs", "test_aepack",
                             "test_plistlib", "test_scriptpackages"]

Deleted: /python/branches/p3yk/Lib/test/test_imageop.py
==============================================================================
--- /python/branches/p3yk/Lib/test/test_imageop.py	Sun May 20 09:31:57 2007
+++ (empty file)
@@ -1,177 +0,0 @@
-#! /usr/bin/env python
-
-"""Test script for the imageop module.  This has the side
-   effect of partially testing the imgfile module as well.
-   Roger E. Masse
-"""
-
-from test.test_support import verbose, unlink
-
-import imageop, uu, os
-
-import warnings
-warnings.filterwarnings("ignore",
-                        "the rgbimg module is deprecated",
-                        DeprecationWarning,
-                        ".*test_imageop")
-
-def main(use_rgbimg=1):
-
-    # Create binary test files
-    uu.decode(get_qualified_path('testrgb'+os.extsep+'uue'), 'test'+os.extsep+'rgb')
-
-    if use_rgbimg:
-        image, width, height = getrgbimage('test'+os.extsep+'rgb')
-    else:
-        image, width, height = getimage('test'+os.extsep+'rgb')
-
-    # Return the selected part of image, which should by width by height
-    # in size and consist of pixels of psize bytes.
-    if verbose:
-        print('crop')
-    newimage = imageop.crop (image, 4, width, height, 0, 0, 1, 1)
-
-    # Return image scaled to size newwidth by newheight. No interpolation
-    # is done, scaling is done by simple-minded pixel duplication or removal.
-    # Therefore, computer-generated images or dithered images will
-    # not look nice after scaling.
-    if verbose:
-        print('scale')
-    scaleimage = imageop.scale(image, 4, width, height, 1, 1)
-
-    # Run a vertical low-pass filter over an image. It does so by computing
-    # each destination pixel as the average of two vertically-aligned source
-    # pixels. The main use of this routine is to forestall excessive flicker
-    # if the image two vertically-aligned source pixels,  hence the name.
-    if verbose:
-        print('tovideo')
-    videoimage = imageop.tovideo (image, 4, width, height)
-
-    # Convert an rgb image to an 8 bit rgb
-    if verbose:
-        print('rgb2rgb8')
-    greyimage = imageop.rgb2rgb8(image, width, height)
-
-    # Convert an 8 bit rgb image to a 24 bit rgb image
-    if verbose:
-        print('rgb82rgb')
-    image = imageop.rgb82rgb(greyimage, width, height)
-
-    # Convert an rgb image to an 8 bit greyscale image
-    if verbose:
-        print('rgb2grey')
-    greyimage = imageop.rgb2grey(image, width, height)
-
-    # Convert an 8 bit greyscale image to a 24 bit rgb image
-    if verbose:
-        print('grey2rgb')
-    image = imageop.grey2rgb(greyimage, width, height)
-
-    # Convert a 8-bit deep greyscale image to a 1-bit deep image by
-    # thresholding all the pixels. The resulting image is tightly packed
-    # and is probably only useful as an argument to mono2grey.
-    if verbose:
-        print('grey2mono')
-    monoimage = imageop.grey2mono (greyimage, width, height, 0)
-
-    # monoimage, width, height = getimage('monotest.rgb')
-    # Convert a 1-bit monochrome image to an 8 bit greyscale or color image.
-    # All pixels that are zero-valued on input get value p0 on output and
-    # all one-value input pixels get value p1 on output. To convert a
-    # monochrome  black-and-white image to greyscale pass the values 0 and
-    # 255 respectively.
-    if verbose:
-        print('mono2grey')
-    greyimage = imageop.mono2grey (monoimage, width, height, 0, 255)
-
-    # Convert an 8-bit greyscale image to a 1-bit monochrome image using a
-    # (simple-minded) dithering algorithm.
-    if verbose:
-        print('dither2mono')
-    monoimage = imageop.dither2mono (greyimage, width, height)
-
-    # Convert an 8-bit greyscale image to a 4-bit greyscale image without
-    # dithering.
-    if verbose:
-        print('grey2grey4')
-    grey4image = imageop.grey2grey4 (greyimage, width, height)
-
-    # Convert an 8-bit greyscale image to a 2-bit greyscale image without
-    # dithering.
-    if verbose:
-        print('grey2grey2')
-    grey2image = imageop.grey2grey2 (greyimage, width, height)
-
-    # Convert an 8-bit greyscale image to a 2-bit greyscale image with
-    # dithering. As for dither2mono, the dithering algorithm is currently
-    # very simple.
-    if verbose:
-        print('dither2grey2')
-    grey2image = imageop.dither2grey2 (greyimage, width, height)
-
-    # Convert a 4-bit greyscale image to an 8-bit greyscale image.
-    if verbose:
-        print('grey42grey')
-    greyimage = imageop.grey42grey (grey4image, width, height)
-
-    # Convert a 2-bit greyscale image to an 8-bit greyscale image.
-    if verbose:
-        print('grey22grey')
-    image = imageop.grey22grey (grey2image, width, height)
-
-    # Cleanup
-    unlink('test'+os.extsep+'rgb')
-
-def getrgbimage(name):
-    """return a tuple consisting of image (in 'imgfile' format but
-    using rgbimg instead) width and height"""
-
-    import rgbimg
-
-    try:
-        sizes = rgbimg.sizeofimage(name)
-    except rgbimg.error:
-        name = get_qualified_path(name)
-        sizes = rgbimg.sizeofimage(name)
-    if verbose:
-        print('rgbimg opening test image: %s, sizes: %s' % (name, str(sizes)))
-
-    image = rgbimg.longimagedata(name)
-    return (image, sizes[0], sizes[1])
-
-def getimage(name):
-    """return a tuple consisting of
-       image (in 'imgfile' format) width and height
-    """
-
-    import imgfile
-
-    try:
-        sizes = imgfile.getsizes(name)
-    except imgfile.error:
-        name = get_qualified_path(name)
-        sizes = imgfile.getsizes(name)
-    if verbose:
-        print('imgfile opening test image: %s, sizes: %s' % (name, str(sizes)))
-
-    image = imgfile.read(name)
-    return (image, sizes[0], sizes[1])
-
-def get_qualified_path(name):
-    """ return a more qualified path to name"""
-    import sys
-    import os
-    path = sys.path
-    try:
-        path = [os.path.dirname(__file__)] + path
-    except NameError:
-        pass
-    for dir in path:
-        fullname = os.path.join(dir, name)
-        if os.path.exists(fullname):
-            return fullname
-    return name
-
-# rgbimg (unlike imgfile) is portable to platforms other than SGI.
-# So we prefer to use it.
-main(use_rgbimg=1)

Modified: python/branches/p3yk/Misc/NEWS
==============================================================================
--- python/branches/p3yk/Misc/NEWS	(original)
+++ python/branches/p3yk/Misc/NEWS	Sun May 20 09:31:57 2007
@@ -178,6 +178,9 @@
 Extension Modules
 -----------------
 
+- Remove the imageop module.  Obsolete long with its unit tests becoming
+  useless from the removal of rgbimg and imgfile.
+
 - isCallable() and sequenceIncludes() have been removed from the operator
   module.
 

Modified: python/branches/p3yk/Modules/Setup.dist
==============================================================================
--- python/branches/p3yk/Modules/Setup.dist	(original)
+++ python/branches/p3yk/Modules/Setup.dist	Sun May 20 09:31:57 2007
@@ -218,7 +218,6 @@
 # These represent audio samples or images as strings:
 
 #audioop audioop.c	# Operations on audio samples
-#imageop imageop.c	# Operations on images
 #rgbimg rgbimgmodule.c	# Read SGI RGB image files (but coded portably)
 
 

Deleted: /python/branches/p3yk/Modules/imageop.c
==============================================================================
--- /python/branches/p3yk/Modules/imageop.c	Sun May 20 09:31:57 2007
+++ (empty file)
@@ -1,785 +0,0 @@
-
-/* imageopmodule - Various operations on pictures */
-
-#ifdef sun
-#define signed
-#endif
-
-#include "Python.h"
-
-#if SIZEOF_INT == 4
-typedef int Py_Int32;
-typedef unsigned int Py_UInt32;
-#else
-#if SIZEOF_LONG == 4
-typedef long Py_Int32;
-typedef unsigned long Py_UInt32;
-#else
-#error "No 4-byte integral type"
-#endif
-#endif
-
-#define CHARP(cp, xmax, x, y) ((char *)(cp+y*xmax+x))
-#define SHORTP(cp, xmax, x, y) ((short *)(cp+2*(y*xmax+x)))
-#define LONGP(cp, xmax, x, y) ((Py_Int32 *)(cp+4*(y*xmax+x)))
-
-static PyObject *ImageopError;
-static PyObject *ImageopDict;
-
-/* If this function returns true (the default if anything goes wrong), we're
-   behaving in a backward-compatible way with respect to how multi-byte pixels
-   are stored in the strings.  The code in this module was originally written
-   for an SGI which is a big-endian system, and so the old code assumed that
-   4-byte integers hold the R, G, and B values in a particular order.
-   However, on little-endian systems the order is reversed, and so not
-   actually compatible with what gl.lrectwrite and imgfile expect.
-   (gl.lrectwrite and imgfile are also SGI-specific, however, it is
-   conceivable that the data handled here comes from or goes to an SGI or that
-   it is otherwise used in the expectation that the byte order in the strings
-   is as specified.)
-
-   The function returns the value of the module variable
-   "backward_compatible", or 1 if the variable does not exist or is not an
-   int.
- */
-
-static int
-imageop_backward_compatible(void)
-{
-	static PyObject *bcos;
-	PyObject *bco;
-	long rc;
-
-	if (ImageopDict == NULL) /* "cannot happen" */
-		return 1;
-	if (bcos == NULL) {
-		/* cache string object for future use */
-		bcos = PyString_FromString("backward_compatible");
-		if (bcos == NULL)
-			return 1;
-	}
-	bco = PyDict_GetItem(ImageopDict, bcos);
-	if (bco == NULL)
-		return 1;
-	if (!PyInt_Check(bco))
-		return 1;
-	rc = PyInt_AsLong(bco);
-	if (PyErr_Occurred()) {
-		/* not an integer, or too large, or something */
-		PyErr_Clear();
-		rc = 1;
-	}
-	return rc != 0;		/* convert to values 0, 1 */
-}
-
-static PyObject *
-imageop_crop(PyObject *self, PyObject *args)
-{
-	char *cp, *ncp;
-	short *nsp;
-	Py_Int32 *nlp;
-	int len, size, x, y, newx1, newx2, newy1, newy2;
-	int ix, iy, xstep, ystep;
-	PyObject *rv;
-
-	if ( !PyArg_ParseTuple(args, "s#iiiiiii", &cp, &len, &size, &x, &y,
-			  &newx1, &newy1, &newx2, &newy2) )
-		return 0;
-    
-	if ( size != 1 && size != 2 && size != 4 ) {
-		PyErr_SetString(ImageopError, "Size should be 1, 2 or 4");
-		return 0;
-	}
-	if ( len != size*x*y ) {
-		PyErr_SetString(ImageopError, "String has incorrect length");
-		return 0;
-	}
-	xstep = (newx1 < newx2)? 1 : -1;
-	ystep = (newy1 < newy2)? 1 : -1;
-    
-	rv = PyString_FromStringAndSize(NULL,
-			     (abs(newx2-newx1)+1)*(abs(newy2-newy1)+1)*size);
-	if ( rv == 0 )
-		return 0;
-	ncp = (char *)PyString_AsString(rv);
-	nsp = (short *)ncp;
-	nlp = (Py_Int32 *)ncp;
-	newy2 += ystep;
-	newx2 += xstep;
-	for( iy = newy1; iy != newy2; iy+=ystep ) {
-		for ( ix = newx1; ix != newx2; ix+=xstep ) {
-			if ( iy < 0 || iy >= y || ix < 0 || ix >= x ) {
-				if ( size == 1 )
-					*ncp++ = 0;
-				else
-					*nlp++ = 0;
-			} else {
-				if ( size == 1 )
-					*ncp++ = *CHARP(cp, x, ix, iy);
-				else if ( size == 2 )
-					*nsp++ = *SHORTP(cp, x, ix, iy);
-				else
-					*nlp++ = *LONGP(cp, x, ix, iy);
-			}
-		}
-	}
-	return rv;
-}
- 
-static PyObject *
-imageop_scale(PyObject *self, PyObject *args)
-{
-	char *cp, *ncp;
-	short *nsp;
-	Py_Int32 *nlp;
-	int len, size, x, y, newx, newy;
-	int ix, iy;
-	int oix, oiy;
-	PyObject *rv;
-
-	if ( !PyArg_ParseTuple(args, "s#iiiii",
-			  &cp, &len, &size, &x, &y, &newx, &newy) )
-		return 0;
-    
-	if ( size != 1 && size != 2 && size != 4 ) {
-		PyErr_SetString(ImageopError, "Size should be 1, 2 or 4");
-		return 0;
-	}
-	if ( len != size*x*y ) {
-		PyErr_SetString(ImageopError, "String has incorrect length");
-		return 0;
-	}
-    
-	rv = PyString_FromStringAndSize(NULL, newx*newy*size);
-	if ( rv == 0 )
-		return 0;
-	ncp = (char *)PyString_AsString(rv);
-	nsp = (short *)ncp;
-	nlp = (Py_Int32 *)ncp;
-	for( iy = 0; iy < newy; iy++ ) {
-		for ( ix = 0; ix < newx; ix++ ) {
-			oix = ix * x / newx;
-			oiy = iy * y / newy;
-			if ( size == 1 )
-				*ncp++ = *CHARP(cp, x, oix, oiy);
-			else if ( size == 2 )
-				*nsp++ = *SHORTP(cp, x, oix, oiy);
-			else
-				*nlp++ = *LONGP(cp, x, oix, oiy);
-		}
-	}
-	return rv;
-}
-
-/* Note: this routine can use a bit of optimizing */
-
-static PyObject *
-imageop_tovideo(PyObject *self, PyObject *args)
-{
-	int maxx, maxy, x, y, len;
-	int i;
-	unsigned char *cp, *ncp;
-	int width;
-	PyObject *rv;
-   
-    
-	if ( !PyArg_ParseTuple(args, "s#iii", &cp, &len, &width, &maxx, &maxy) )
-		return 0;
-
-	if ( width != 1 && width != 4 ) {
-		PyErr_SetString(ImageopError, "Size should be 1 or 4");
-		return 0;
-	}
-	if ( maxx*maxy*width != len ) {
-		PyErr_SetString(ImageopError, "String has incorrect length");
-		return 0;
-	}
-    
-	rv = PyString_FromStringAndSize(NULL, len);
-	if ( rv == 0 )
-		return 0;
-	ncp = (unsigned char *)PyString_AsString(rv);
-
-	if ( width == 1 ) {
-		memcpy(ncp, cp, maxx);		/* Copy first line */
-		ncp += maxx;
-		for (y=1; y<maxy; y++) {	/* Interpolate other lines */
-			for(x=0; x<maxx; x++) {
-				i = y*maxx + x;
-				*ncp++ = ((int)cp[i] + (int)cp[i-maxx]) >> 1;
-			}
-		}
-	} else {
-		memcpy(ncp, cp, maxx*4);		/* Copy first line */
-		ncp += maxx*4;
-		for (y=1; y<maxy; y++) {	/* Interpolate other lines */
-			for(x=0; x<maxx; x++) {
-				i = (y*maxx + x)*4 + 1;
-				*ncp++ = 0;	/* Skip alfa comp */
-				*ncp++ = ((int)cp[i] + (int)cp[i-4*maxx]) >> 1;
-				i++;
-				*ncp++ = ((int)cp[i] + (int)cp[i-4*maxx]) >> 1;
-				i++;
-				*ncp++ = ((int)cp[i] + (int)cp[i-4*maxx]) >> 1;
-			}
-		}
-	}
-	return rv;
-}
-
-static PyObject *
-imageop_grey2mono(PyObject *self, PyObject *args)
-{
-	int tres, x, y, len;
-	unsigned char *cp, *ncp;
-	unsigned char ovalue;
-	PyObject *rv;
-	int i, bit;
-   
-    
-	if ( !PyArg_ParseTuple(args, "s#iii", &cp, &len, &x, &y, &tres) )
-		return 0;
-
-	if ( x*y != len ) {
-		PyErr_SetString(ImageopError, "String has incorrect length");
-		return 0;
-	}
-    
-	rv = PyString_FromStringAndSize(NULL, (len+7)/8);
-	if ( rv == 0 )
-		return 0;
-	ncp = (unsigned char *)PyString_AsString(rv);
-
-	bit = 0x80;
-	ovalue = 0;
-	for ( i=0; i < len; i++ ) {
-		if ( (int)cp[i] > tres )
-			ovalue |= bit;
-		bit >>= 1;
-		if ( bit == 0 ) {
-			*ncp++ = ovalue;
-			bit = 0x80;
-			ovalue = 0;
-		}
-	}
-	if ( bit != 0x80 )
-		*ncp++ = ovalue;
-	return rv;
-}
-
-static PyObject *
-imageop_grey2grey4(PyObject *self, PyObject *args)
-{
-	int x, y, len;
-	unsigned char *cp, *ncp;
-	unsigned char ovalue;
-	PyObject *rv;
-	int i;
-	int pos;
-   
-    
-	if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
-		return 0;
-
-	if ( x*y != len ) {
-		PyErr_SetString(ImageopError, "String has incorrect length");
-		return 0;
-	}
-    
-	rv = PyString_FromStringAndSize(NULL, (len+1)/2);
-	if ( rv == 0 )
-		return 0;
-	ncp = (unsigned char *)PyString_AsString(rv);
-	pos = 0;
-	ovalue = 0;
-	for ( i=0; i < len; i++ ) {
-		ovalue |= ((int)cp[i] & 0xf0) >> pos;
-		pos += 4;
-		if ( pos == 8 ) {
-			*ncp++ = ovalue;
-			ovalue = 0;
-			pos = 0;
-		}
-	}
-	if ( pos != 0 )
-		*ncp++ = ovalue;
-	return rv;
-}
-
-static PyObject *
-imageop_grey2grey2(PyObject *self, PyObject *args)
-{
-	int x, y, len;
-	unsigned char *cp, *ncp;
-	unsigned char ovalue;
-	PyObject *rv;
-	int i;
-	int pos;
-   
-    
-	if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
-		return 0;
-
-	if ( x*y != len ) {
-		PyErr_SetString(ImageopError, "String has incorrect length");
-		return 0;
-	}
-    
-	rv = PyString_FromStringAndSize(NULL, (len+3)/4);
-	if ( rv == 0 )
-		return 0;
-	ncp = (unsigned char *)PyString_AsString(rv);
-	pos = 0;
-	ovalue = 0;
-	for ( i=0; i < len; i++ ) {
-		ovalue |= ((int)cp[i] & 0xc0) >> pos;
-		pos += 2;
-		if ( pos == 8 ) {
-			*ncp++ = ovalue;
-			ovalue = 0;
-			pos = 0;
-		}
-	}
-	if ( pos != 0 )
-		*ncp++ = ovalue;
-	return rv;
-}
-
-static PyObject *
-imageop_dither2mono(PyObject *self, PyObject *args)
-{
-	int sum, x, y, len;
-	unsigned char *cp, *ncp;
-	unsigned char ovalue;
-	PyObject *rv;
-	int i, bit;
-   
-    
-	if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
-		return 0;
-
-	if ( x*y != len ) {
-		PyErr_SetString(ImageopError, "String has incorrect length");
-		return 0;
-	}
-    
-	rv = PyString_FromStringAndSize(NULL, (len+7)/8);
-	if ( rv == 0 )
-		return 0;
-	ncp = (unsigned char *)PyString_AsString(rv);
-
-	bit = 0x80;
-	ovalue = 0;
-	sum = 0;
-	for ( i=0; i < len; i++ ) {
-		sum += cp[i];
-		if ( sum >= 256 ) {
-			sum -= 256;
-			ovalue |= bit;
-		}
-		bit >>= 1;
-		if ( bit == 0 ) {
-			*ncp++ = ovalue;
-			bit = 0x80;
-			ovalue = 0;
-		}
-	}
-	if ( bit != 0x80 )
-		*ncp++ = ovalue;
-	return rv;
-}
-
-static PyObject *
-imageop_dither2grey2(PyObject *self, PyObject *args)
-{
-	int x, y, len;
-	unsigned char *cp, *ncp;
-	unsigned char ovalue;
-	PyObject *rv;
-	int i;
-	int pos;
-	int sum = 0, nvalue;
-   
-    
-	if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
-		return 0;
-
-	if ( x*y != len ) {
-		PyErr_SetString(ImageopError, "String has incorrect length");
-		return 0;
-	}
-    
-	rv = PyString_FromStringAndSize(NULL, (len+3)/4);
-	if ( rv == 0 )
-		return 0;
-	ncp = (unsigned char *)PyString_AsString(rv);
-	pos = 1;
-	ovalue = 0;
-	for ( i=0; i < len; i++ ) {
-		sum += cp[i];
-		nvalue = sum & 0x180;
-		sum -= nvalue;
-		ovalue |= nvalue >> pos;
-		pos += 2;
-		if ( pos == 9 ) {
-			*ncp++ = ovalue;
-			ovalue = 0;
-			pos = 1;
-		}
-	}
-	if ( pos != 0 )
-		*ncp++ = ovalue;
-	return rv;
-}
-
-static PyObject *
-imageop_mono2grey(PyObject *self, PyObject *args)
-{
-	int v0, v1, x, y, len, nlen;
-	unsigned char *cp, *ncp;
-	PyObject *rv;
-	int i, bit;
-    
-	if ( !PyArg_ParseTuple(args, "s#iiii", &cp, &len, &x, &y, &v0, &v1) )
-		return 0;
-
-	nlen = x*y;
-	if ( (nlen+7)/8 != len ) {
-		PyErr_SetString(ImageopError, "String has incorrect length");
-		return 0;
-	}
-    
-	rv = PyString_FromStringAndSize(NULL, nlen);
-	if ( rv == 0 )
-		return 0;
-	ncp = (unsigned char *)PyString_AsString(rv);
-
-	bit = 0x80;
-	for ( i=0; i < nlen; i++ ) {
-		if ( *cp & bit )
-			*ncp++ = v1;
-		else
-			*ncp++ = v0;
-		bit >>= 1;
-		if ( bit == 0 ) {
-			bit = 0x80;
-			cp++;
-		}
-	}
-	return rv;
-}
-
-static PyObject *
-imageop_grey22grey(PyObject *self, PyObject *args)
-{
-	int x, y, len, nlen;
-	unsigned char *cp, *ncp;
-	PyObject *rv;
-	int i, pos, value = 0, nvalue;
-    
-	if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
-		return 0;
-
-	nlen = x*y;
-	if ( (nlen+3)/4 != len ) {
-		PyErr_SetString(ImageopError, "String has incorrect length");
-		return 0;
-	}
-    
-	rv = PyString_FromStringAndSize(NULL, nlen);
-	if ( rv == 0 )
-		return 0;
-	ncp = (unsigned char *)PyString_AsString(rv);
-
-	pos = 0;
-	for ( i=0; i < nlen; i++ ) {
-		if ( pos == 0 ) {
-			value = *cp++;
-			pos = 8;
-		}
-		pos -= 2;
-		nvalue = (value >> pos) & 0x03;
-		*ncp++ = nvalue | (nvalue << 2) |
-			 (nvalue << 4) | (nvalue << 6);
-	}
-	return rv;
-}
-
-static PyObject *
-imageop_grey42grey(PyObject *self, PyObject *args)
-{
-	int x, y, len, nlen;
-	unsigned char *cp, *ncp;
-	PyObject *rv;
-	int i, pos, value = 0, nvalue;
-    
-	if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
-		return 0;
-
-	nlen = x*y;
-	if ( (nlen+1)/2 != len ) {
-		PyErr_SetString(ImageopError, "String has incorrect length");
-		return 0;
-	}
-    
-	rv = PyString_FromStringAndSize(NULL, nlen);
-	if ( rv == 0 )
-		return 0;
-	ncp = (unsigned char *)PyString_AsString(rv);
-
-	pos = 0;
-	for ( i=0; i < nlen; i++ ) {
-		if ( pos == 0 ) {
-			value = *cp++;
-			pos = 8;
-		}
-		pos -= 4;
-		nvalue = (value >> pos) & 0x0f;
-		*ncp++ = nvalue | (nvalue << 4);
-	}
-	return rv;
-}
-
-static PyObject *
-imageop_rgb2rgb8(PyObject *self, PyObject *args)
-{
-	int x, y, len, nlen;
-	unsigned char *cp;
-	unsigned char *ncp;
-	PyObject *rv;
-	int i, r, g, b;
-	int backward_compatible = imageop_backward_compatible();
-    
-	if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
-		return 0;
-
-	nlen = x*y;
-	if ( nlen*4 != len ) {
-		PyErr_SetString(ImageopError, "String has incorrect length");
-		return 0;
-	}
-    
-	rv = PyString_FromStringAndSize(NULL, nlen);
-	if ( rv == 0 )
-		return 0;
-	ncp = (unsigned char *)PyString_AsString(rv);
-
-	for ( i=0; i < nlen; i++ ) {
-		/* Bits in source: aaaaaaaa BBbbbbbb GGGggggg RRRrrrrr */
-		if (backward_compatible) {
-			Py_UInt32 value = * (Py_UInt32 *) cp;
-			cp += 4;
-			r = (int) ((value & 0xff) / 255. * 7. + .5);
-			g = (int) (((value >> 8) & 0xff) / 255. * 7. + .5);
-			b = (int) (((value >> 16) & 0xff) / 255. * 3. + .5);
-		} else {
-			cp++;		/* skip alpha channel */
-			b = (int) (*cp++ / 255. * 3. + .5);
-			g = (int) (*cp++ / 255. * 7. + .5);
-			r = (int) (*cp++ / 255. * 7. + .5);
-		}
-		*ncp++ = (unsigned char)((r<<5) | (b<<3) | g);
-	}
-	return rv;
-}
-
-static PyObject *
-imageop_rgb82rgb(PyObject *self, PyObject *args)
-{
-	int x, y, len, nlen;
-	unsigned char *cp;
-	unsigned char *ncp;
-	PyObject *rv;
-	int i, r, g, b;
-	unsigned char value;
-	int backward_compatible = imageop_backward_compatible();
-    
-	if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
-		return 0;
-
-	nlen = x*y;
-	if ( nlen != len ) {
-		PyErr_SetString(ImageopError, "String has incorrect length");
-		return 0;
-	}
-    
-	rv = PyString_FromStringAndSize(NULL, nlen*4);
-	if ( rv == 0 )
-		return 0;
-	ncp = (unsigned char *)PyString_AsString(rv);
-
-	for ( i=0; i < nlen; i++ ) {
-		/* Bits in source: RRRBBGGG
-		** Red and Green are multiplied by 36.5, Blue by 85
-		*/
-		value = *cp++;
-		r = (value >> 5) & 7;
-		g = (value     ) & 7;
-		b = (value >> 3) & 3;
-		r = (r<<5) | (r<<3) | (r>>1);
-		g = (g<<5) | (g<<3) | (g>>1);
-		b = (b<<6) | (b<<4) | (b<<2) | b;
-		if (backward_compatible) {
-			Py_UInt32 nvalue = r | (g<<8) | (b<<16);
-			* (Py_UInt32 *) ncp = nvalue;
-			ncp += 4;
-		} else {
-			*ncp++ = 0;
-			*ncp++ = b;
-			*ncp++ = g;
-			*ncp++ = r;
-		}
-	}
-	return rv;
-}
-
-static PyObject *
-imageop_rgb2grey(PyObject *self, PyObject *args)
-{
-	int x, y, len, nlen;
-	unsigned char *cp;
-	unsigned char *ncp;
-	PyObject *rv;
-	int i, r, g, b;
-	int nvalue;
-	int backward_compatible = imageop_backward_compatible();
-    
-	if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
-		return 0;
-
-	nlen = x*y;
-	if ( nlen*4 != len ) {
-		PyErr_SetString(ImageopError, "String has incorrect length");
-		return 0;
-	}
-    
-	rv = PyString_FromStringAndSize(NULL, nlen);
-	if ( rv == 0 )
-		return 0;
-	ncp = (unsigned char *)PyString_AsString(rv);
-
-	for ( i=0; i < nlen; i++ ) {
-		if (backward_compatible) {
-			Py_UInt32 value = * (Py_UInt32 *) cp;
-			cp += 4;
-			r = (int) ((value & 0xff) / 255. * 7. + .5);
-			g = (int) (((value >> 8) & 0xff) / 255. * 7. + .5);
-			b = (int) (((value >> 16) & 0xff) / 255. * 3. + .5);
-		} else {
-			cp++;		/* skip alpha channel */
-			b = *cp++;
-			g = *cp++;
-			r = *cp++;
-		}
-		nvalue = (int)(0.30*r + 0.59*g + 0.11*b);
-		if ( nvalue > 255 ) nvalue = 255;
-		*ncp++ = (unsigned char)nvalue;
-	}
-	return rv;
-}
-
-static PyObject *
-imageop_grey2rgb(PyObject *self, PyObject *args)
-{
-	int x, y, len, nlen;
-	unsigned char *cp;
-	unsigned char *ncp;
-	PyObject *rv;
-	int i;
-	unsigned char value;
-	int backward_compatible = imageop_backward_compatible();
-    
-	if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
-		return 0;
-
-	nlen = x*y;
-	if ( nlen != len ) {
-		PyErr_SetString(ImageopError, "String has incorrect length");
-		return 0;
-	}
-    
-	rv = PyString_FromStringAndSize(NULL, nlen*4);
-	if ( rv == 0 )
-		return 0;
-	ncp = (unsigned char *)PyString_AsString(rv);
-
-	for ( i=0; i < nlen; i++ ) {
-		value = *cp++;
-		if (backward_compatible) {
-			* (Py_UInt32 *) ncp = (Py_UInt32) value | ((Py_UInt32) value << 8 ) | ((Py_UInt32) value << 16);
-			ncp += 4;
-		} else {
-			*ncp++ = 0;
-			*ncp++ = value;
-			*ncp++ = value;
-			*ncp++ = value;
-		}
-	}
-	return rv;
-}
-
-/*
-static object *
-imageop_mul(object *self, object *args)
-{
-	char *cp, *ncp;
-	int len, size, x, y;
-	object *rv;
-	int i;
-
-	if ( !getargs(args, "(s#iii)", &cp, &len, &size, &x, &y) )
-		return 0;
-    
-	if ( size != 1 && size != 4 ) {
-		err_setstr(ImageopError, "Size should be 1 or 4");
-		return 0;
-	}
-	if ( len != size*x*y ) {
-		err_setstr(ImageopError, "String has incorrect length");
-		return 0;
-	}
-    
-	rv = newsizedstringobject(NULL, XXXX);
-	if ( rv == 0 )
-		return 0;
-	ncp = (char *)getstringvalue(rv);
-    
-    
-	for ( i=0; i < len; i += size ) {
-	}
-	return rv;
-}
-*/
-
-static PyMethodDef imageop_methods[] = {
-	{ "crop",		imageop_crop, METH_VARARGS },
-	{ "scale",		imageop_scale, METH_VARARGS },
-	{ "grey2mono",	        imageop_grey2mono, METH_VARARGS },
-	{ "grey2grey2",	        imageop_grey2grey2, METH_VARARGS },
-	{ "grey2grey4",	        imageop_grey2grey4, METH_VARARGS },
-	{ "dither2mono",	imageop_dither2mono, METH_VARARGS },
-	{ "dither2grey2",	imageop_dither2grey2, METH_VARARGS },
-	{ "mono2grey",	        imageop_mono2grey, METH_VARARGS },
-	{ "grey22grey",	        imageop_grey22grey, METH_VARARGS },
-	{ "grey42grey",	        imageop_grey42grey, METH_VARARGS },
-	{ "tovideo",	        imageop_tovideo, METH_VARARGS },
-	{ "rgb2rgb8",	        imageop_rgb2rgb8, METH_VARARGS },
-	{ "rgb82rgb",	        imageop_rgb82rgb, METH_VARARGS },
-	{ "rgb2grey",	        imageop_rgb2grey, METH_VARARGS },
-	{ "grey2rgb",	        imageop_grey2rgb, METH_VARARGS },
-	{ 0,                    0 }
-};
-
-
-PyMODINIT_FUNC
-initimageop(void)
-{
-	PyObject *m;
-	m = Py_InitModule("imageop", imageop_methods);
-	if (m == NULL)
-		return;
-	ImageopDict = PyModule_GetDict(m);
-	ImageopError = PyErr_NewException("imageop.error", NULL, NULL);
-	if (ImageopError != NULL)
-		PyDict_SetItemString(ImageopDict, "error", ImageopError);
-}

Modified: python/branches/p3yk/README
==============================================================================
--- python/branches/p3yk/README	(original)
+++ python/branches/p3yk/README	Sun May 20 09:31:57 2007
@@ -292,7 +292,7 @@
 
 XXX I think this next bit is out of date:
 
-64-bit platforms: The modules audioop, imageop and rgbimg don't work.
+64-bit platforms: The audioop module doesn't work.
         The setup.py script disables them on 64-bit installations.
         Don't try to enable them in the Modules/Setup file.  They
         contain code that is quite wordsize sensitive.  (If you have a
@@ -462,11 +462,11 @@
            your system... tested here at QNX with the following modules:
 
                 array, audioop, binascii, cPickle, cStringIO, cmath,
-                crypt, curses, errno, fcntl, gdbm, grp, imageop,
+                crypt, curses, errno, fcntl, gdbm, grp,
                 _locale, math, md5, new, operator, parser, pcre,
                 posix, pwd, readline, regex, reop, rgbimg, rotor,
                 select, signal, socket, soundex, struct,
-                syslog, termios, time, timing, zlib, audioop, imageop, rgbimg
+                syslog, termios, time, timing, zlib, audioop
 
         3) make SHELL=/usr/local/bin/bash
 

Modified: python/branches/p3yk/setup.py
==============================================================================
--- python/branches/p3yk/setup.py	(original)
+++ python/branches/p3yk/setup.py	Sun May 20 09:31:57 2007
@@ -504,15 +504,6 @@
         # 64-bit platforms.
         exts.append( Extension('audioop', ['audioop.c']) )
 
-        # Disabled on 64-bit platforms
-        if sys.maxint != 9223372036854775807:
-            # Operations on images
-            exts.append( Extension('imageop', ['imageop.c']) )
-            # Read SGI RGB image files (but coded portably)
-            exts.append( Extension('rgbimg', ['rgbimgmodule.c']) )
-        else:
-            missing.extend(['imageop', 'rgbimg'])
-
         # readline
         do_readline = self.compiler.find_library_file(lib_dirs, 'readline')
         if platform == 'darwin':


More information about the Python-3000-checkins mailing list