Ejemplo n.º 1
0
    def test_blit_rect(self):
        surface = RSDL.CreateRGBSurface(0, 150, 50, 32,
                                        r_uint(0x000000FF),
                                        r_uint(0x0000FF00),
                                        r_uint(0x00FF0000),
                                        r_uint(0xFF000000))
        fmt = surface.c_format
        color = RSDL.MapRGB(fmt, 255, 0, 0)
        RSDL.FillRect(surface, lltype.nullptr(RSDL.Rect), color)
        
        paintrect = RSDL_helper.mallocrect(75, 0, 150, 50)
        dstrect = lltype.malloc(RSDL.Rect, flavor='raw')
        try:
            color = RSDL.MapRGB(fmt, 255, 128, 0)
            RSDL.FillRect(surface, paintrect, color)

            rffi.setintfield(dstrect, 'c_x',  10)
            rffi.setintfield(dstrect, 'c_y',  10)
            rffi.setintfield(dstrect, 'c_w', 150)
            rffi.setintfield(dstrect, 'c_h',  50)
            RSDL.BlitSurface(surface, lltype.nullptr(RSDL.Rect), self.screen, dstrect)
            RSDL.Flip(self.screen)
        finally:
            lltype.free(dstrect, flavor='raw')
            lltype.free(paintrect, flavor='raw')
        RSDL.FreeSurface(surface)
        self.check("Half Red/Orange rectangle(150px * 50px) at the top left, 10 pixels from the border")
Ejemplo n.º 2
0
 def setup_method(self, meth):
     self.dst_surf = RSDL.CreateRGBSurface(0, 300, 300, 32,
                                           r_uint(0x000000FF),
                                           r_uint(0x0000FF00),
                                           r_uint(0x00FF0000),
                                           r_uint(0x00000000))
     self.src_surf = RSDL.CreateRGBSurface(0, 50, 50, 32,
                                           r_uint(0x000000FF),
                                           r_uint(0x0000FF00),
                                           r_uint(0x00FF0000),
                                           r_uint(0x00000000))
     fmt = self.src_surf.c_format
     self.black = RSDL.MapRGB(fmt, 0, 0, 0)
     self.red = RSDL.MapRGB(fmt, 255, 0, 0)
     self.blue = RSDL.MapRGB(fmt, 0, 0, 255)
     RSDL.FillRect(self.src_surf, lltype.nullptr(RSDL.Rect), self.red)
Ejemplo n.º 3
0
def test_surface_basic():
    assert RSDL.Init(RSDL.INIT_VIDEO) >= 0
    surface = RSDL.CreateRGBSurface(0, 150, 50, 32, r_uint(0x000000FF),
                                    r_uint(0x0000FF00), r_uint(0x00FF0000),
                                    r_uint(0xFF000000))
    assert surface
    assert rffi.getintfield(surface, 'c_w') == 150
    assert rffi.getintfield(surface, 'c_h') == 50
    RSDL.FreeSurface(surface)
    RSDL.Quit()