Commits

Lenard Lindstrom committed 4cf1001

Using Numeric by default now issues a deprecation warning. Fix hanging pointer bug in color.c.

  • Participants
  • Parent commits 70825b9

Comments (0)

Files changed (8)

 # BREAK = change breaks existing code
 # BUG    = fixed a bug that was (or could have been) crashing
 
-[SVN 3000-3001] Feb 20, 2011
+[SVN 3006] Feb 24, 2011
+    [BUG] Fix hanging pointer problem in color.c.
+    Add deprecation warning for Numeric in surfarray and sndarray.
+
+[SVN 3003-3005] Feb 21-24, 2011
+    Enhance array support in pixelcopy methods. map_array now accepts
+    a three byte integer for target array. Surface.get_view now
+    allows a 2D view for 24 bitsized arrays, even though not accepted
+    by numpy. Color objects now export an array struct interface.
+    Various bug fixes for Python 3.1.
+
+[SVN 3000-3002] Feb 20, 2011
     Merge the surface_buffer branch back into trunk.
     1) Rename module _arraysurfarray to pixelcopy, which implements
        array_to_surface (blit_surface), surface_to_array, and map_array.

File docs/ref/sndarray.html

 <p>Each sample is an 8-bit or 16-bit integer, depending on the data format. <tt>A</tt> stereo sound file has two values per sample, while a mono sound file only has one. </p>
 <p>Supported array systems are </p>
 <pre>  numpy
-  numeric
-</pre><p>The default will be numpy, if installed. Otherwise, Numeric will be set as default if installed. If neither numpy nor Numeric are installed, the module will raise an ImportError. </p>
+  numeric (deprecated; to be removed in Pygame 1.9.3.)
+</pre><p>The default will be numpy, if installed. Otherwise, Numeric will be set as default if installed, and a deprecation warning will be issued. If neither numpy nor Numeric are installed, the module will raise an ImportError. </p>
 <p>The array type to use can be changed at runtime using the use_arraytype() method, which requires one of the above types as string. </p>
 <p>Note: numpy and Numeric are not completely compatible. Certain array manipulations, which work for one type, might behave differently or even completely break for the other. </p>
 <p>Additionally, in contrast to Numeric numpy can use unsigned 16-bit integers. Sounds with 16-bit data will be treated as unsigned integers, if the sound sample type requests this. Numeric instead always uses signed integers for the representation, which is important to keep in mind, if you use the module's functions and wonder about the values. </p>
+<p>numpy support added in Pygame <tt>1.8</tt> Official Numeric deprecation begins in Pygame <tt>1.9.2</tt>. </p>
 <!--COMMENTS:pygame.sndarray--> &nbsp;<br> 
 
 
   <i>Sets the array system to be used for sound arrays</i><br>
   <tt>pygame.sndarray.use_arraytype (arraytype): return None</tt><br>
 <p>Uses the requested array type for the module functions. Currently supported array types are: </p>
-<pre>  numeric
+<pre>  numeric (deprecated; will be removed in Pygame 1.9.3.)
   numpy
 </pre><p>If the requested type is not available, a ValueError will be raised. </p>
 <p>New in pygame <tt>1.8</tt>. </p>

File docs/ref/surfarray.html

 <p>The arrays are indexed by the <tt>X</tt> axis first, followed by the <tt>Y</tt> axis. Arrays that treat the pixels as a single integer are referred to as <tt>2D</tt> arrays. This module can also separate the red, green, and blue color values into separate indices. These types of arrays are referred to as <tt>3D</tt> arrays, and the last index is 0 for red, 1 for green, and 2 for blue. </p>
 <p>Supported array systems are </p>
 <pre>  numpy
-  numeric
-</pre><p>The default will be numpy, if installed. Otherwise, Numeric will be set as default if installed. If neither numpy nor Numeric are installed, the module will raise an ImportError. </p>
+  numeric (deprecated; to be removed in Pygame 1.9.3.)
+</pre><p>The default will be numpy, if installed. Otherwise, Numeric will be set as default if installed, and a deprecation warning will be issued. If neither numpy nor Numeric are installed, the module will raise an ImportError. </p>
 <p>The array type to use can be changed at runtime using the use_arraytype () method, which requires one of the above types as string. </p>
 <p>Note: numpy and Numeric are not completely compatible. Certain array manipulations, which work for one type, might behave differently or even completely break for the other. </p>
-<p>Additionally, in contrast to Numeric numpy does use unsigned 16-bit integers. Images with 16-bit data will be treated as unsigned integers. Numeric instead uses signed integers for the representation, which is important to keep in mind, if you use the module's functions and wonder about the values. </p>
-<p>The support of numpy is new in pygame <tt>1.8</tt>. </p>
+<p>Additionally, in contrast to Numeric, numpy does use unsigned 16-bit integers. Images with 16-bit data will be treated as unsigned integers. Numeric instead uses signed integers for the representation, which is important to keep in mind, if you use the module's functions and wonder about the values. </p>
+<p>The support of numpy is new in Pygame <tt>1.8</tt>. Official Numeric deprecation begins in Pygame <tt>1.9.2</tt>. </p>
 <!--COMMENTS:pygame.surfarray--> &nbsp;<br> 
 
 
   <i>Sets the array system to be used for surface arrays</i><br>
   <tt>pygame.surfarray.use_arraytype (arraytype): return None</tt><br>
 <p>Uses the requested array type for the module functions. Currently supported array types are: </p>
-<pre>  numeric
+<pre>  numeric (deprecated; will be removed in Pygame 1.9.3.)
   numpy
 </pre><p>If the requested type is not available, a ValueError will be raised. </p>
 <p>New in pygame <tt>1.8</tt>. </p>

File lib/sndarray.doc

 Supported array systems are
 
   numpy
-  numeric
+  numeric (deprecated; to be removed in Pygame 1.9.3.)
 
 The default will be numpy, if installed. Otherwise, Numeric will be set
-as default if installed. If neither numpy nor Numeric are installed, the
-module will raise an ImportError.
+as default if installed, and a deprecation warning will be issued.
+If neither numpy nor Numeric are installed,
+the module will raise an ImportError.
 
 The array type to use can be changed at runtime using the use_arraytype()
 method, which requires one of the above types as string.
 if the sound sample type requests this. Numeric instead always uses
 signed integers for the representation, which is important to keep in
 mind, if you use the module's functions and wonder about the values.
+
+numpy support added in Pygame 1.8
+Official Numeric deprecation begins in Pygame 1.9.2.
 <SECTION>
 
 array
 Uses the requested array type for the module functions.
 Currently supported array types are:
 
-  numeric 
+  numeric (deprecated; will be removed in Pygame 1.9.3.)
   numpy
 
 If the requested type is not available, a ValueError will be raised.

File lib/sndarray.py

 Supported array systems are
 
   numpy
-  numeric
+  numeric (deprecated; to be removed in Pygame 1.9.3.)
 
 The default will be numpy, if installed. Otherwise, Numeric will be set
-as default if installed. If neither numpy nor Numeric are installed, the
-module will raise an ImportError.
+as default if installed, and a deprecation warning will be issued.
+If neither numpy nor Numeric are installed, the module will raise an
+ImportError.
 
 The array type to use can be changed at runtime using the use_arraytype()
 method, which requires one of the above types as string.
 """
 
 import pygame
+import imp
 
 # Global array type setting. See use_arraytype().
 __arraytype = None
     __hasnumpy = False
 
 try:
-    import pygame._numericsndarray as numericsnd
+    if not __hasnumpy:
+        import pygame._numericsndarray as numericsnd
+        __arraytype = "numeric"
+        warnings.warn(warnings.DeprecationWarning(
+                "Numeric support to be removed in Pygame 1.9.3"))
+    else:
+        f, p, d = imp.find_module("Numeric")
     __hasnumeric = True
-    if not __hasnumpy:
-        __arraytype = "numeric"
 except ImportError:
     __hasnumeric = False
 
     Uses the requested array type for the module functions.
     Currently supported array types are:
 
-      numeric 
+      numeric (deprecated; will be removed in Pygame 1.9.3.)
       numpy
 
     If the requested type is not available, a ValueError will be raised.
     arraytype = arraytype.lower ()
     if arraytype == "numeric":
         if __hasnumeric:
+            import pygame._numericsndarray as numericsnd
             __arraytype = arraytype
         else:
             raise ValueError("Numeric arrays are not available")

File lib/surfarray.doc

 Supported array systems are
 
   numpy
-  numeric
+  numeric (deprecated; to be removed in Pygame 1.9.3.)
 
 The default will be numpy, if installed. Otherwise, Numeric will be set
-as default if installed. If neither numpy nor Numeric are installed, the
-module will raise an ImportError.
+as default if installed, and a deprecation warning will be issued.
+If neither numpy nor Numeric are installed,
+the module will raise an ImportError.
 
 The array type to use can be changed at runtime using the use_arraytype ()
 method, which requires one of the above types as string.
 manipulations, which work for one type, might behave differently or even
 completely break for the other.
 
-Additionally, in contrast to Numeric numpy does use unsigned 16-bit
+Additionally, in contrast to Numeric, numpy does use unsigned 16-bit
 integers. Images with 16-bit data will be treated as unsigned
 integers. Numeric instead uses signed integers for the representation,
 which is important to keep in mind, if you use the module's functions
 and wonder about the values.
 
-The support of numpy is new in pygame 1.8.
+The support of numpy is new in Pygame 1.8.
+Official Numeric deprecation begins in Pygame 1.9.2.
 <SECTION>
 
 array2d
 Uses the requested array type for the module functions.
 Currently supported array types are:
 
-  numeric 
+  numeric (deprecated; will be removed in Pygame 1.9.3.)
   numpy
 
 If the requested type is not available, a ValueError will be raised.

File lib/surfarray.py

 Supported array types are
 
   numpy
-  numeric
+  numeric (deprecated; will be removed in Pygame 1.9.3.)
 
 The default will be numpy, if installed. Otherwise, Numeric will be set
-as default if installed. If neither numpy nor Numeric are installed, the
-module will raise an ImportError.
+as default if installed, and a deprecation warning will be issued. If
+neither numpy nor Numeric are installed, the module will raise an
+ImportError.
 
 The array type to use can be changed at runtime using the use_arraytype()
 method, which requires one of the above types as string.
 manipulations, which work for one type, might behave differently or even
 completely break for the other.
 
-Additionally, in contrast to Numeric numpy does use unsigned 16-bit
+Additionally, in contrast to Numeric, numpy does use unsigned 16-bit
 integers. Images with 16-bit data will be treated as unsigned
 integers. Numeric instead uses signed integers for the representation,
 which is important to keep in mind, if you use the module's functions
 """
 
 import pygame
+import imp
+import warnings
 
 # Global array type setting. See use_arraytype().
 __arraytype = None
     __hasnumpy = False
 
 try:
-    import pygame._numericsurfarray as numericsf
+    if not __hasnumpy:
+        import pygame._numericsurfarray as numericsf
+        __arraytype = "numeric"
+        warnings.warn(warnings.DeprecationWarning(
+                "Numeric support to be removed in Pygame 1.9.3"))
+    else:
+        f, p, d = imp.find_module('Numeric')
+        f.close()
     __hasnumeric = True
-    if not __hasnumpy:
-        __arraytype = "numeric"
 except ImportError:
     __hasnumeric = False
 
     Uses the requested array type for the module functions.
     Currently supported array types are:
 
-      numeric 
+      numeric (deprecated; to be removed in Pygame 1.9.3)
       numpy
 
     If the requested type is not available, a ValueError will be raised.
     """
     global __arraytype
+    global numericsf
 
     arraytype = arraytype.lower ()
     if arraytype == "numeric":
         if __hasnumeric:
+            import pygame._numericsurfarray as numericsf
             __arraytype = arraytype
         else:
             raise ValueError("Numeric arrays are not available")
-        
     elif arraytype == "numpy":
         if __hasnumpy:
             __arraytype = arraytype
     Uint8 g;
     Uint8 b;
     Uint8 a;
+    Uint8 data[4];
     Uint8 len;
 } PyColor;
 
     ((o)->ob_type == (PyTypeObject *) &PyColor_Type)
 
 #define RGB_EQUALS(x,y)                          \
-    ((((PyColor *)x)->r == ((PyColor *)y)->r) && \
-     (((PyColor *)x)->g == ((PyColor *)y)->g) && \
-     (((PyColor *)x)->b == ((PyColor *)y)->b) && \
-     (((PyColor *)x)->a == ((PyColor *)y)->a))
+    ((((PyColor *)x)->data[0] == ((PyColor *)y)->data[0]) && \
+     (((PyColor *)x)->data[1] == ((PyColor *)y)->data[1]) && \
+     (((PyColor *)x)->data[2] == ((PyColor *)y)->data[2]) && \
+     (((PyColor *)x)->data[3] == ((PyColor *)y)->data[3]))
 
 static int
 _get_double (PyObject *obj, double *val)
 {
     if (PyType_IsSubtype (obj->ob_type, &PyColor_Type))
     {
-	rgba[0] = ((PyColor *) obj)->r;
-	rgba[1] = ((PyColor *) obj)->g;
-	rgba[2] = ((PyColor *) obj)->b;
-	rgba[3] = ((PyColor *) obj)->a;
+	rgba[0] = ((PyColor *) obj)->data[0];
+	rgba[1] = ((PyColor *) obj)->data[1];
+	rgba[2] = ((PyColor *) obj)->data[2];
+	rgba[3] = ((PyColor *) obj)->data[3];
 	return 1;
     }
     else if (PyType_IsSubtype (obj->ob_type, &PyTuple_Type))
     if (!color)
         return NULL;
 
-    color->r = rgba[0];
-    color->g = rgba[1];
-    color->b = rgba[2];
-    color->a = rgba[3];
+    color->data[0] = rgba[0];
+    color->data[1] = rgba[1];
+    color->data[2] = rgba[2];
+    color->data[3] = rgba[3];
     color->len = length;
 
     return color;
     /* Max. would be (255, 255, 255, 255) */
     char buf[21];
     PyOS_snprintf (buf, sizeof (buf), "(%d, %d, %d, %d)",
-        color->r, color->g, color->b, color->a);
+        color->data[0], color->data[1], color->data[2], color->data[3]);
     return Text_FromUTF8 (buf);
 }
 
 _color_normalize (PyColor *color)
 {
     double rgba[4];
-    rgba[0] = color->r / 255.0;
-    rgba[1] = color->g / 255.0;
-    rgba[2] = color->b / 255.0;
-    rgba[3] = color->a / 255.0;
+    rgba[0] = color->data[0] / 255.0;
+    rgba[1] = color->data[1] / 255.0;
+    rgba[2] = color->data[2] / 255.0;
+    rgba[3] = color->data[3] / 255.0;
     return Py_BuildValue ("(ffff)", rgba[0], rgba[1], rgba[2], rgba[3]);
 }
 
     if (!PyArg_ParseTuple (args, "d", &_gamma))
         return NULL;
 
-    frgba[0] = pow (color->r / 255.0, _gamma);
-    frgba[1] = pow (color->g / 255.0, _gamma);
-    frgba[2] = pow (color->b / 255.0, _gamma);
-    frgba[3] = pow (color->a / 255.0, _gamma);
+    frgba[0] = pow (color->data[0] / 255.0, _gamma);
+    frgba[1] = pow (color->data[1] / 255.0, _gamma);
+    frgba[2] = pow (color->data[2] / 255.0, _gamma);
+    frgba[3] = pow (color->data[3] / 255.0, _gamma);
 
     /* visual studio doesn't have a round func, so doing it with +.5 and
      * truncaction */
 static PyObject*
 _color_get_r (PyColor *color, void *closure)
 {
-    return PyInt_FromLong (color->r);
+    return PyInt_FromLong (color->data[0]);
 }
 
 /**
         PyErr_SetString (PyExc_ValueError, "color exceeds allowed range");
         return -1;
     }
-    color->r = c;
+    color->data[0] = c;
     return 0;
 }
 
 static PyObject*
 _color_get_g (PyColor *color, void *closure)
 {
-    return PyInt_FromLong (color->g);
+    return PyInt_FromLong (color->data[1]);
 }
 
 /**
         PyErr_SetString (PyExc_ValueError, "color exceeds allowed range");
         return -1;
     }
-    color->g = c;
+    color->data[1] = c;
     return 0;
 }
 
 static PyObject*
 _color_get_b (PyColor *color, void *closure)
 {
-    return PyInt_FromLong (color->b);
+    return PyInt_FromLong (color->data[2]);
 }
 
 /**
         PyErr_SetString (PyExc_ValueError, "color exceeds allowed range");
         return -1;
     }
-    color->b = c;
+    color->data[2] = c;
     return 0;
 }
 
 static PyObject*
 _color_get_a (PyColor *color, void *closure)
 {
-    return PyInt_FromLong (color->a);
+    return PyInt_FromLong (color->data[3]);
 }
 
 /**
         PyErr_SetString (PyExc_ValueError, "color exceeds allowed range");
         return -1;
     }
-    color->a = c;
+    color->data[3] = c;
     return 0;
 }
 
     double minv, maxv, diff;
 
     /* Normalize */
-    frgb[0] = color->r / 255.0;
-    frgb[1] = color->g / 255.0;
-    frgb[2] = color->b / 255.0;
-    frgb[3] = color->a / 255.0;
+    frgb[0] = color->data[0] / 255.0;
+    frgb[1] = color->data[1] / 255.0;
+    frgb[2] = color->data[2] / 255.0;
+    frgb[3] = color->data[3] / 255.0;
 
     maxv = MAX (MAX (frgb[0], frgb[1]), frgb[2]);
     minv = MIN (MIN (frgb[0], frgb[1]), frgb[2]);
         Py_DECREF (item);
     }
 
-    color->a = (Uint8) ((hsva[3] / 100.0f) * 255);
+    color->data[3] = (Uint8) ((hsva[3] / 100.0f) * 255);
 
     s = hsva[1] / 100.f;
     v = hsva[2] / 100.f;
     switch (hi)
     {
     case 0:
-        color->r = (Uint8) (v * 255);
-        color->g = (Uint8) (t * 255);
-        color->b = (Uint8) (p * 255);
+        color->data[0] = (Uint8) (v * 255);
+        color->data[1] = (Uint8) (t * 255);
+        color->data[2] = (Uint8) (p * 255);
         break;
     case 1:
-        color->r = (Uint8) (q * 255);
-        color->g = (Uint8) (v * 255);
-        color->b = (Uint8) (p * 255);
+        color->data[0] = (Uint8) (q * 255);
+        color->data[1] = (Uint8) (v * 255);
+        color->data[2] = (Uint8) (p * 255);
         break;
     case 2:
-        color->r = (Uint8) (p * 255);
-        color->g = (Uint8) (v * 255);
-        color->b = (Uint8) (t * 255);
+        color->data[0] = (Uint8) (p * 255);
+        color->data[1] = (Uint8) (v * 255);
+        color->data[2] = (Uint8) (t * 255);
         break;
     case 3:
-        color->r = (Uint8) (p * 255);
-        color->g = (Uint8) (q * 255);
-        color->b = (Uint8) (v * 255);
+        color->data[0] = (Uint8) (p * 255);
+        color->data[1] = (Uint8) (q * 255);
+        color->data[2] = (Uint8) (v * 255);
         break;
     case 4:
-        color->r = (Uint8) (t * 255);
-        color->g = (Uint8) (p * 255);
-        color->b = (Uint8) (v * 255);
+        color->data[0] = (Uint8) (t * 255);
+        color->data[1] = (Uint8) (p * 255);
+        color->data[2] = (Uint8) (v * 255);
         break;
     case 5:
-        color->r = (Uint8) (v * 255);
-        color->g = (Uint8) (p * 255);
-        color->b = (Uint8) (q * 255);
+        color->data[0] = (Uint8) (v * 255);
+        color->data[1] = (Uint8) (p * 255);
+        color->data[2] = (Uint8) (q * 255);
         break;
     default:
         PyErr_SetString (PyExc_OverflowError,
     double minv, maxv, diff;
 
     /* Normalize */
-    frgb[0] = color->r / 255.0;
-    frgb[1] = color->g / 255.0;
-    frgb[2] = color->b / 255.0;
-    frgb[3] = color->a / 255.0;
+    frgb[0] = color->data[0] / 255.0;
+    frgb[1] = color->data[1] / 255.0;
+    frgb[2] = color->data[2] / 255.0;
+    frgb[3] = color->data[3] / 255.0;
 
     maxv = MAX (MAX (frgb[0], frgb[1]), frgb[2]);
     minv = MIN (MIN (frgb[0], frgb[1]), frgb[2]);
         Py_DECREF (item);
     }
 
-    color->a = (Uint8) ((hsla[3] / 100.f) * 255);
+    color->data[3] = (Uint8) ((hsla[3] / 100.f) * 255);
 
     s = hsla[1] / 100.f;
     l = hsla[2] / 100.f;
 
     if (s == 0)
     {
-        color->r = (Uint8) (l * 255);
-        color->g = (Uint8) (l * 255);
-        color->b = (Uint8) (l * 255);
+        color->data[0] = (Uint8) (l * 255);
+        color->data[1] = (Uint8) (l * 255);
+        color->data[2] = (Uint8) (l * 255);
         return 0;
     }
 
         h -= 1;
 
     if (h < 1./6.f)
-        color->r = (Uint8) ((p + ((q - p) * 6 * h)) * 255);
+        color->data[0] = (Uint8) ((p + ((q - p) * 6 * h)) * 255);
     else if (h < 0.5f)
-        color->r = (Uint8) (q * 255);
+        color->data[0] = (Uint8) (q * 255);
     else if (h < 2./3.f)
-        color->r = (Uint8) ((p + ((q - p) * 6 * (2./3.f - h))) * 255);
+        color->data[0] = (Uint8) ((p + ((q - p) * 6 * (2./3.f - h))) * 255);
     else
-        color->r = (Uint8) (p * 255);
+        color->data[0] = (Uint8) (p * 255);
 
     /* Calculate G */
     h = ht;
         h -= 1;
 
     if (h < 1./6.f)
-        color->g = (Uint8) ((p + ((q - p) * 6 * h)) * 255);
+        color->data[1] = (Uint8) ((p + ((q - p) * 6 * h)) * 255);
     else if (h < 0.5f)
-        color->g = (Uint8) (q * 255);
+        color->data[1] = (Uint8) (q * 255);
     else if (h < 2./3.f)
-        color->g = (Uint8) ((p + ((q - p) * 6 * (2./3.f - h))) * 255);
+        color->data[1] = (Uint8) ((p + ((q - p) * 6 * (2./3.f - h))) * 255);
     else
-        color->g = (Uint8) (p * 255);
+        color->data[1] = (Uint8) (p * 255);
 
     /* Calculate B */
     h = ht - onethird;
         h -= 1;
 
     if (h < 1./6.f)
-        color->b = (Uint8) ((p + ((q - p) * 6 * h)) * 255);
+        color->data[2] = (Uint8) ((p + ((q - p) * 6 * h)) * 255);
     else if (h < 0.5f)
-        color->b = (Uint8) (q * 255);
+        color->data[2] = (Uint8) (q * 255);
     else if (h < 2./3.f)
-        color->b = (Uint8) ((p + ((q - p) * 6 * (2./3.f - h))) * 255);
+        color->data[2] = (Uint8) ((p + ((q - p) * 6 * (2./3.f - h))) * 255);
     else
-        color->b = (Uint8) (p * 255);
+        color->data[2] = (Uint8) (p * 255);
 
     return 0;
 }
     double frgb[3];
 
     /* Normalize */
-    frgb[0] = color->r / 255.0;
-    frgb[1] = color->g / 255.0;
-    frgb[2] = color->b / 255.0;
+    frgb[0] = color->data[0] / 255.0;
+    frgb[1] = color->data[1] / 255.0;
+    frgb[2] = color->data[2] / 255.0;
     
     i1i2i3[0] = (frgb[0] + frgb[1] + frgb[2]) / 3.0f;
     i1i2i3[1] = (frgb[0] - frgb[2]) / 2.0f;
     ar = 2 * i1i2i3[1] + ab;
     ag = 3 * i1i2i3[0] - ar - ab;
 
-    color->r = (Uint8) (ar * 255);
-    color->g = (Uint8) (ag * 255);
-    color->b = (Uint8) (ab * 255);
+    color->data[0] = (Uint8) (ar * 255);
+    color->data[1] = (Uint8) (ag * 255);
+    color->data[2] = (Uint8) (ab * 255);
 
     return 0;
 }
     double frgb[3];
 
     /* Normalize */
-    frgb[0] = color->r / 255.0;
-    frgb[1] = color->g / 255.0;
-    frgb[2] = color->b / 255.0;
+    frgb[0] = color->data[0] / 255.0;
+    frgb[1] = color->data[1] / 255.0;
+    frgb[2] = color->data[2] / 255.0;
     
     cmy[0] = 1.0 - frgb[0];
     cmy[1] = 1.0 - frgb[1];
     }
     Py_DECREF (item);
     
-    color->r = (Uint8) ((1.0 - cmy[0]) * 255);
-    color->g = (Uint8) ((1.0 - cmy[1]) * 255);
-    color->b = (Uint8) ((1.0 - cmy[2]) * 255);
+    color->data[0] = (Uint8) ((1.0 - cmy[0]) * 255);
+    color->data[1] = (Uint8) ((1.0 - cmy[1]) * 255);
+    color->data[2] = (Uint8) ((1.0 - cmy[2]) * 255);
 
     return 0;
 }
     typedef struct {
         PyArrayInterface inter;
         Py_intptr_t shape[1];
-        Uint8 data[4];
     } _color_view_t;
     _color_view_t *view = PyMem_New(_color_view_t, 1);
     PyObject *cobj;
         return PyErr_NoMemory();
     }
     view->shape[0] = color->len;
-    view->data[0] = color->r;
-    view->data[1] = color->g;
-    view->data[2] = color->b;
-    view->data[3] = color->a;
     view->inter.two = 2;
     view->inter.nd = 1;
     view->inter.typekind = 'u';
                          PAI_ALIGNED | PAI_NOTSWAPPED);
     view->inter.shape = view->shape;
     view->inter.strides = &(view->inter.itemsize);
-    view->inter.data = view->data;
+    view->inter.data = color->data;
     
     cobj = PyCapsule_New(view, NULL, _color_freeview);
     if (!cobj) {
 _color_add (PyColor *color1, PyColor *color2)
 {
     Uint8 rgba[4];
-    rgba[0] = MIN (color1->r + color2->r, 255);
-    rgba[1] = MIN (color1->g + color2->g, 255);
-    rgba[2] = MIN (color1->b + color2->b, 255);
-    rgba[3] = MIN (color1->a + color2->a, 255);
+    rgba[0] = MIN (color1->data[0] + color2->data[0], 255);
+    rgba[1] = MIN (color1->data[1] + color2->data[1], 255);
+    rgba[2] = MIN (color1->data[2] + color2->data[2], 255);
+    rgba[3] = MIN (color1->data[3] + color2->data[3], 255);
     return (PyObject*) _color_new_internal (&PyColor_Type, rgba);
 }
 
 _color_sub (PyColor *color1, PyColor *color2)
 {
     Uint8 rgba[4];
-    rgba[0] = MAX (color1->r - color2->r, 0);
-    rgba[1] = MAX (color1->g - color2->g, 0);
-    rgba[2] = MAX (color1->b - color2->b, 0);
-    rgba[3] = MAX (color1->a - color2->a, 0);
+    rgba[0] = MAX (color1->data[0] - color2->data[0], 0);
+    rgba[1] = MAX (color1->data[1] - color2->data[1], 0);
+    rgba[2] = MAX (color1->data[2] - color2->data[2], 0);
+    rgba[3] = MAX (color1->data[3] - color2->data[3], 0);
     return (PyObject*) _color_new_internal (&PyColor_Type, rgba);
 }
 
 _color_mul (PyColor *color1, PyColor *color2)
 {
     Uint8 rgba[4];
-    rgba[0] = MIN (color1->r * color2->r, 255);
-    rgba[1] = MIN (color1->g * color2->g, 255);
-    rgba[2] = MIN (color1->b * color2->b, 255);
-    rgba[3] = MIN (color1->a * color2->a, 255);
+    rgba[0] = MIN (color1->data[0] * color2->data[0], 255);
+    rgba[1] = MIN (color1->data[1] * color2->data[1], 255);
+    rgba[2] = MIN (color1->data[2] * color2->data[2], 255);
+    rgba[3] = MIN (color1->data[3] * color2->data[3], 255);
     return (PyObject*) _color_new_internal (&PyColor_Type, rgba);
 }
 
 _color_div (PyColor *color1, PyColor *color2)
 {
     Uint8 rgba[4] = { 0, 0, 0, 0 };
-    if (color2->r != 0)
-        rgba[0] = color1->r / color2->r;
-    if (color2->g != 0)
-        rgba[1] = color1->g / color2->g;
-    if (color2->b)
-        rgba[2] = color1->b / color2->b;
-    if (color2->a)
-        rgba[3] = color1->a / color2->a;
+    if (color2->data[0] != 0)
+        rgba[0] = color1->data[0] / color2->data[0];
+    if (color2->data[1] != 0)
+        rgba[1] = color1->data[1] / color2->data[1];
+    if (color2->data[2])
+        rgba[2] = color1->data[2] / color2->data[2];
+    if (color2->data[3])
+        rgba[3] = color1->data[3] / color2->data[3];
     return (PyObject*) _color_new_internal (&PyColor_Type, rgba);
 }
 
 _color_mod (PyColor *color1, PyColor *color2)
 {
     Uint8 rgba[4];
-    rgba[0] = color1->r % color2->r;
-    rgba[1] = color1->g % color2->g;
-    rgba[2] = color1->b % color2->b;
-    rgba[3] = color1->a % color2->a;
+    rgba[0] = color1->data[0] % color2->data[0];
+    rgba[1] = color1->data[1] % color2->data[1];
+    rgba[2] = color1->data[2] % color2->data[2];
+    rgba[3] = color1->data[3] % color2->data[3];
     return (PyObject*) _color_new_internal (&PyColor_Type, rgba);
 }
 
 _color_inv (PyColor *color)
 {
     Uint8 rgba[4];
-    rgba[0] = 255 - color->r;
-    rgba[1] = 255 - color->g;
-    rgba[2] = 255 - color->b;
-    rgba[3] = 255 - color->a;
+    rgba[0] = 255 - color->data[0];
+    rgba[1] = 255 - color->data[1];
+    rgba[2] = 255 - color->data[2];
+    rgba[3] = 255 - color->data[3];
     return (PyObject*) _color_new_internal (&PyColor_Type, rgba);
 }
 
 static PyObject*
 _color_int (PyColor *color)
 {
-    Uint32 tmp = (color->r << 24) + (color->g << 16) + 
-                 (color->b << 8) + color->a;
+    Uint32 tmp = (color->data[0] << 24) + (color->data[1] << 16) + 
+                 (color->data[2] << 8) + color->data[3];
 #if !PY3
     if (tmp < LONG_MAX)
         return PyInt_FromLong ((long) tmp);
 static PyObject*
 _color_long (PyColor *color)
 {
-    Uint32 tmp = (color->r << 24) + (color->g << 16) + (color->b << 8) +
-        color->a;
+    Uint32 tmp = ((color->data[0] << 24) +
+                  (color->data[1] << 16) +
+                  (color->data[2] << 8) +
+                  color->data[3]);
     return PyLong_FromUnsignedLong (tmp);
 }
 
 static PyObject*
 _color_float (PyColor *color)
 {
-    Uint32 tmp = (color->r << 24) + (color->g << 16) + (color->b << 8) +
-        color->a;
+    Uint32 tmp = ((color->data[0] << 24) +
+                  (color->data[1] << 16) +
+                  (color->data[2] << 8) +
+                  color->data[3]);
     return PyFloat_FromDouble ((double) tmp);
 }
 
 _color_oct (PyColor *color)
 {
     char buf[100];
-    Uint32 tmp = (color->r << 24) + (color->g << 16) + (color->b << 8) +
-        color->a;
+    Uint32 tmp = ((color->data[0] << 24) +
+                  (color->data[1] << 16) +
+                  (color->data[2] << 8) +
+                  color->data[3]);
 
     if (tmp < LONG_MAX)
         PyOS_snprintf (buf, sizeof (buf), "0%lo", (unsigned long) tmp);
 _color_hex (PyColor *color)
 {
     char buf[100];
-    Uint32 tmp = (color->r << 24) + (color->g << 16) + (color->b << 8) +
-        color->a;
+    Uint32 tmp = ((color->data[0] << 24) +
+                  (color->data[1] << 16) +
+                  (color->data[2] << 8) +
+                  color->data[3]);
     if (tmp < LONG_MAX)
         PyOS_snprintf (buf, sizeof (buf), "0x%lx", (unsigned long) tmp);
     else
     switch (_index)
     {
     case 0:
-        return PyInt_FromLong (color->r);
+        return PyInt_FromLong (color->data[0]);
     case 1:
-        return PyInt_FromLong (color->g);
+        return PyInt_FromLong (color->data[1]);
     case 2:
-        return PyInt_FromLong (color->b);
+        return PyInt_FromLong (color->data[2]);
     case 3:
-        return PyInt_FromLong (color->a);
+        return PyInt_FromLong (color->data[3]);
     default:
         return RAISE (PyExc_IndexError, "invalid index");
     }
         /* printf("2 ilow :%d:, ihigh:%d: len:%d:\n", ilow, ihigh, len); */
         
         if(ilow == 0) {
-            c1 = a->r;
-            c2 = a->g;
-            c3 = a->b;
-            c4 = a->a;
+            c1 = a->data[0];
+            c2 = a->data[1];
+            c3 = a->data[2];
+            c4 = a->data[3];
         } else if(ilow == 1) {
-            c1 = a->g;
-            c2 = a->b;
-            c3 = a->a;
+            c1 = a->data[1];
+            c2 = a->data[2];
+            c3 = a->data[3];
 
         } else if(ilow == 2) {
-            c1 = a->b;
-            c2 = a->a;
+            c1 = a->data[2];
+            c2 = a->data[3];
 
         } else if(ilow == 3) {
-            c1 = a->a;
+            c1 = a->data[3];
         }
 
 
 {
     if (PyColor_Check (color))
     {
-        rgba[0] = ((PyColor *) color)->r;
-        rgba[1] = ((PyColor *) color)->g;
-        rgba[2] = ((PyColor *) color)->b;
-        rgba[3] = ((PyColor *) color)->a;
+        rgba[0] = ((PyColor *) color)->data[0];
+        rgba[1] = ((PyColor *) color)->data[1];
+        rgba[2] = ((PyColor *) color)->data[2];
+        rgba[3] = ((PyColor *) color)->data[3];
         return 1;
     }
     else