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

Re: [pygame] [PATCH] Surface.set_at() on BIG ENDIAN machines



Hey,

thanks for that.  I have put applied the patch in cvs*1

Can someone on big endian(powerpc macosx, solaris etc) please try out
cvs to test if this works for them?

Cheers,


1* except I changed it to use the preprocessor to avoid the if at runtime.

#if (SDL_BYTEORDER == SDL_LIL_ENDIAN)
                        *(byte_buf + (format->Rshift >> 3)) = rgb[0];
                        *(byte_buf + (format->Gshift >> 3)) = rgb[1];
                        *(byte_buf + (format->Bshift >> 3)) = rgb[2];
#else
                        *(byte_buf + 2 - (format->Rshift >> 3)) = rgb[0];
                        *(byte_buf + 2 - (format->Gshift >> 3)) = rgb[1];
                        *(byte_buf + 2 - (format->Bshift >> 3)) = rgb[2];
#endif




On 1/7/06, Ivo Danihelka <ivo@xxxxxxxxxxxxx> wrote:
> Hi,
>
> there seems to be bug in function Surface.set_at(). This bug appears
> with 24-bit color depth Surface on BIG ENDIAN machines.
>
> I've attached patch for CVS version of pygame. The nicer solution would
> be also to remove the code duplicities between src/draw.c:set_at() and
> src/sruface.c:surf_set_at().
>
> The other attached file "testSetAt.py" is simple script that should show
> the bug. Please, try it on PowerPC machines.
> Its correct output should be:
> ==========
> bytes per pixel: 3
> old color expected: (100, 200, 255, 255)
> old color: (100, 200, 255, 255)
> new color expected: (10, 20, 30, 255)
> new color: (10, 20, 30, 255)
> ==========
>
> Note that function Surface.get_at() is correct, and you can use
> Surface.fill(color, (position, (1,1))) instead of
> Surface.set_at(position, color).
>
> --
> Ivo Danihelka
>
>
>