예제 #1
0
 def test_rw_from_file(self):
     rw = rwops.rw_from_file(self.testfile, "r")
     self.assertIsInstance(rw, rwops.SDL_RWops)
     # Read the first 42 bytes(sic!). It should be:
     # 'This is a test file for pygame2.sdl.rwops!'
     length = 42
     buf = BytesIO()
     while length >= 2:
         # Reading in two bytes - we have plain text(1-byte encoding), so
         # we read in 2 characters at a time. This means that the first
         # character is always stored in the lo byte.
         ch = rwops.read_le_16(rw)
         buf.write(byteify(chr(ch & 0x00FF), "utf-8"))
         buf.write(byteify(chr(ch >> 8), "utf-8"))
         length -= 2
     self.assertEqual(stringify(buf.getvalue(), "utf-8"),
                      "This is a test file for pygame2.sdl.rwops!")
예제 #2
0
파일: surface.py 프로젝트: gdos/pgreloaded
def save_bmp(surface, filename):
    """Saves a surface to a file.
    """
    rw = rwops.rw_from_file(filename, "wb")
    save_bmp_rw(surface, rw, True)
예제 #3
0
파일: surface.py 프로젝트: gdos/pgreloaded
def load_bmp(filename):
    """Loads a surface from a BMP file.
    """
    rw = rwops.rw_from_file(str(filename), "rb")
    return load_bmp_rw(rw, True)
예제 #4
0
파일: audio.py 프로젝트: gdos/pgreloaded
def load_wav(filename):
    """TODO
    """
    rwops = rw_from_file(filename, "rb")
    return load_wav_rw(rwops, 1)