Beispiel #1
0
 def from_object(self, obj):
     """Creates a Sprite from an arbitrary object."""
     if self.sprite_type == TEXTURE:
         rw = rwops.rw_from_object(obj)
         # TODO: support arbitrary objects.
         surface = sdlsurface.load_bmp_rw(rw, True)
         s = self.from_surface(surface, True)
     elif self.sprite_type == SOFTWARE:
         rw = rwops.rw_from_object(obj)
         s = SoftwareSprite(sdlsurface.load_bmp_rw(rw, True), True)
     return s
Beispiel #2
0
    def test_load_bmp_rw(self):
        imgfile = RESOURCES.get("surfacetest.bmp")
        imgrw = rwops.rw_from_object(imgfile)
        imgsurface = surface.load_bmp_rw(imgrw, False)
        self.assertIsInstance(imgsurface, surface.SDL_Surface)
        surface.free_surface(imgsurface)

        self.assertRaises(TypeError, surface.load_bmp_rw, "Test")
        self.assertRaises(TypeError, surface.load_bmp_rw, None)
        self.assertRaises(TypeError, surface.load_bmp_rw, 1234)