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

[pygame] Surfarray question



Hi,

I am using surfarray to blit an image.
When i use array2d i see the image being renderer, but with array3d i dont.


I use the following code to load image :

            r_temp_surface = pygame.image.load(fpath).convert_alpha()
            salpha =  r_temp_surface.get_alpha()
            r_surface = pygame.Surface((o_w,o_h)).convert_alpha()
            pygame.transform.smoothscale(r_temp_surface,(o_w,o_h),r_surface)
            #if salpha != None:
            #    r_surface.set_alpha(salpha)
            r_array = pygame.surfarray.array3d(r_surface)
            print "New Surface Alpha: " , r_surface.get_alpha()
            storeObject.lib_set(o_id,"__render_surface",r_surface)
            storeObject.lib_set(o_id,"__render_array",r_array)



To render I use :

        r_myarray = storeObject.lib_get(o_id,"__render_array")
        r_mysurface = storeObject.lib_get(o_id,"__render_surface")
        pygame.surfarray.blit_array(r_mysurface, r_myarray)
        surface.blit  (r_mysurface,(gx,gy))



Plz help.

-Abhinav