[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] [BUG] pixelarray_test.py reports errors then hangs for Python 2.4.4



On, Tue Apr 15, 2008, Lenard Lindstrom wrote:

[...]
Sounds like a memory access bug (24bpp once more, I think).
Can you please give the attached patch a try? It just changes the
precedences for 24bpp pixel assignments slightly.

Regards
Marcus
Index: src/pixelarray_methods.c
===================================================================
--- src/pixelarray_methods.c	(Revision 1216)
+++ src/pixelarray_methods.c	(Arbeitskopie)
@@ -267,9 +267,8 @@
             posx = 0;
             while (posx < array->xlen)
             {
-                px = (Uint8 *) (pixels + vy * newsurf->pitch) + vx * 3;
-                vpx = (Uint8 *) ((Uint8*) origpixels + y * array->padding) +
-                    x * 3;
+                px = ((Uint8 *) (pixels + vy * newsurf->pitch) + vx * 3);
+                vpx = ((Uint8 *) (origpixels + y * array->padding) + x * 3);
 
 #if (SDL_BYTEORDER == SDL_LIL_ENDIAN)
                 *(px + (format->Rshift >> 3)) =
@@ -533,7 +532,7 @@
             posx = 0;
             while (posx < array->xlen)
             {
-                px = (Uint8 *) (pixels + y * surface->pitch) + x * 3;
+                px = ((Uint8 *) (pixels + y * surface->pitch) + x * 3);
 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
                 pxcolor = (px[0]) + (px[1] << 8) + (px[2] << 16);
                 if (distance)
@@ -750,7 +749,7 @@
             posx = 0;
             while (posx < newarray->xlen)
             {
-                px = (Uint8 *) (pixels + y * surface->pitch) + x * 3;
+                px = ((Uint8 *) (pixels + y * surface->pitch) + x * 3);
 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
                 pxcolor = (px[0]) + (px[1] << 8) + (px[2] << 16);
                 if (distance)
@@ -1023,8 +1022,8 @@
             posx = 0;
             while (posx < newarray->xlen)
             {
-                px1 = (Uint8 *) (pixels1 + y * surface1->pitch) + x * 3;
-                px2 = (Uint8 *) (pixels2 + vy * surface2->pitch) + vx * 3;
+                px1 = ((Uint8 *) (pixels1 + y * surface1->pitch) + x * 3);
+                px2 = ((Uint8 *) (pixels2 + vy * surface2->pitch) + vx * 3);
 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
                 pxcolor1 = (px1[0]) + (px1[1] << 8) + (px1[2] << 16);
                 pxcolor2 = (px2[0]) + (px2[1] << 8) + (px2[2] << 16);
Index: src/pixelarray.c
===================================================================
--- src/pixelarray.c	(Revision 1216)
+++ src/pixelarray.c	(Arbeitskopie)
@@ -758,9 +758,8 @@
             x = xstart;
             while (posx < xlen)
             {
-                px = (Uint8 *) (pixels + y * padding) + x * 3;
-                vpx = (Uint8 *) ((Uint8*) valpixels + vy * val->padding) +
-                    vx * 3;
+                px = ((Uint8 *) (pixels + y * padding) + x * 3);
+                vpx = ((Uint8 *) (valpixels + vy * val->padding) + vx * 3);
 
 #if (SDL_BYTEORDER == SDL_LIL_ENDIAN)
                 *(px + (format->Rshift >> 3)) =
@@ -958,7 +957,7 @@
             while (posx < xlen)
             {
                 color = *colorvals++;
-                px = (Uint8 *) (pixels + y * padding) + x * 3;
+                px = ((Uint8 *) (pixels + y * padding) + x * 3);
 #if (SDL_BYTEORDER == SDL_LIL_ENDIAN)
                 *(px + (format->Rshift >> 3)) = (Uint8) (color >> 16);
                 *(px + (format->Gshift >> 3)) = (Uint8) (color >> 8);
@@ -1094,7 +1093,7 @@
             x = xstart;
             while (posx < xlen)
             {
-                px = (Uint8 *) (pixels + y * padding) + x * 3;
+                px = ((Uint8 *) (pixels + y * padding) + x * 3);
 #if (SDL_BYTEORDER == SDL_LIL_ENDIAN)
                 *(px + (format->Rshift >> 3)) = (Uint8) (color >> 16);
                 *(px + (format->Gshift >> 3)) = (Uint8) (color >> 8);
@@ -1253,7 +1252,7 @@
             x = xstart;
             while (posx < xlen)
             {
-                px = (Uint8 *) (pixels + y * padding) + x * 3;
+                px = ((Uint8 *) (pixels + y * padding) + x * 3);
 #if (SDL_BYTEORDER == SDL_LIL_ENDIAN)
                 *(px + (format->Rshift >> 3)) = (Uint8) (color >> 16);
                 *(px + (format->Gshift >> 3)) = (Uint8) (color >> 8);

Attachment: pgpXGirk5CeK4.pgp
Description: PGP signature