[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[pygame] ConvertSurface question....
Hi!
First I must say that I have never programmed SDL in C before...
I was trying to implement a "get_rgba32_data" method to Surface, but I can't make SDL_ConvertSurface() work.. :/
I always get 80 7f 01 01 80 7f 01 01 etc if i fill() the surface first with values >0 first...
if i fill() with (0,0,0,0) I get:
80 7f 00 00 80 7f 00 00...
I guess the error must be in rgba_fmt?
Here is my code from surface.c:
static PyObject* surf_get_rgba32_data(PyObject* self, PyObject* args)
{
SDL_Surface* rgba_surf;
SDL_PixelFormat rgba_fmt;
rgba_fmt.palette = NULL;
rgba_fmt.colorkey = 0;
rgba_fmt.alpha = 0;
rgba_fmt.BitsPerPixel = 32;
rgba_fmt.BytesPerPixel = 4;
rgba_fmt.Rmask = 0x11000000; rgba_fmt.Rshift = 24; rgba_fmt.Rloss = 0;
rgba_fmt.Gmask = 0x00110000; rgba_fmt.Gshift = 16; rgba_fmt.Gloss = 0;
rgba_fmt.Bmask = 0x00001100; rgba_fmt.Bshift = 8; rgba_fmt.Bloss = 0;
rgba_fmt.Amask = 0x00000011; rgba_fmt.Ashift = 0; rgba_fmt.Aloss = 0;
rgba_surf = SDL_ConvertSurface( PySurface_AsSurface(self),
&rgba_fmt,
(SDL_SWSURFACE|SDL_SRCALPHA) );
if( rgba_surf->pixels )
return Py_BuildValue( "s#", rgba_surf->pixels, rgba_surf->w*rgba_surf->h*4 );
else
return NULL;
}
Please help me if you can! I really need this for Freevo!
Regards
Per Wigren
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org