Example #1
0
 def test_acquire_pythonbrasil8(self):
     (nt, sprs) = image.acquire_nametable('fixtures/pythonbrasil8.png')
     # debug
     image.export_chr(sprs, '/tmp/pythonbrasil8_sprite.png')
     # debug
     image.export_nametable(nt, sprs, '/tmp/pythonbrasil8_nametable.png')
     from pynes import write_bin_code
     write_bin_code(nt, '/tmp/pythonbrasil8.bin')
     write_bin_code(sprs[0], '/tmp/pythonbrasil8.chr')
Example #2
0
 def test_acquire_pythonbrasil8(self):
     (nt, sprs) = image.acquire_nametable('fixtures/pythonbrasil8.png')
     #debug 
     image.export_chr(sprs, '/tmp/pythonbrasil8_sprite.png')
     #debug 
     image.export_nametable(nt, sprs, '/tmp/pythonbrasil8_nametable.png')
     from pynes import write_bin_code
     write_bin_code(nt, '/tmp/pythonbrasil8.bin')
     write_bin_code(sprs[0], '/tmp/pythonbrasil8.chr')
Example #3
0
 def test_convert_to_nametable_pythonbrasil(self):
     return
     nt, sprs = image.convert_to_nametable('fixtures/pythonbrasil8.png')
     image.export_chr('sprite.chr', 'pythonbrasil8.png')
     image.export_nametable('nametable.bin','sprite.chr', 'pythonbrasil8.png')
     import os
     os.rename('nametable.bin', 'pythonbrasil8.bin')
     image.export_nametable(
         'fixtures/nerdynights/scrolling/garoa.bin',
         'fixtures/nerdynights/scrolling/sprite.chr',
         'garoa.png')
Example #4
0
    def test_export_chr(self):
        try:
            os.remove('/tmp/mario.png')
        except:
            pass
        self.assertFalse(os.path.exists('/tmp/mario.png'))
        image.export_chr('fixtures/nesasm/scrolling/mario.chr', '/tmp/mario.png')
        self.assertTrue(os.path.exists('/tmp/mario.png'))

        expected = open('fixtures/mario.png', 'rb').read()
        actual = open('/tmp/mario.png', 'rb').read()
        self.assertEquals(expected, actual)

        os.remove('/tmp/mario.png')
Example #5
0
    def test_export_chr(self):
        try:
            os.remove('/tmp/mario.png')
        except:
            pass
        self.assertFileNotExists('/tmp/mario.png')
        image.export_chr('fixtures/nerdynights/scrolling/mario.chr', '/tmp/mario.png')
        self.assertFileExists('/tmp/mario.png')
        self.assertPNGFileEquals('fixtures/mario.png', '/tmp/mario.png')

        img = Image.open('/tmp/mario.png')
        sprs, indexes = image.acquire_chr(img)
        self.assertIsNotNone(sprs)
        self.assertEquals(8192, len(sprs))
        self.assertSpriteEquals(self.mario1, sprite.get_sprite(0, sprs))
        self.assertSpriteEquals(self.mario2, sprite.get_sprite(1, sprs))

        os.remove('/tmp/mario.png')