pygame / test /

aholkner a1df1cc 

aholkner 6b48926 
aholkner a1df1cc 

#!/usr/bin/env python

'''Interoperability test with PIL.

An SDL surface is created for each frame generated by PIL.

__docformat__ = 'restructuredtext'
__version__ = '$Id$'

import math
import os
import sys

from SDL import *
import SDL.array
import Image

DEFAULT_IMAGE = os.path.join(os.path.dirname(sys.argv[0]), 'sample.bmp')

if __name__ == '__main__':

    image_filename = DEFAULT_IMAGE
    if len(sys.argv) > 1:
        image_filename = sys.argv[1]

    src_image =
    size = int(math.sqrt(src_image.size[0]**2 + src_image.size[1]**2) + 0.5)
    original_image ='RGBA', (size, size))
    original_image.paste(src_image, ((size - src_image.size[0]) / 2, 
                                     (size - src_image.size[1]) / 2))

    screen = SDL_SetVideoMode(size, size, 32, 0)

    done = False
    angle = 0
    while not done:
        event = SDL_PollEventAndReturn()
        while event:
            if event.type in (SDL_QUIT, SDL_KEYDOWN):
                done = True
            event = SDL_PollEventAndReturn()

        angle = (angle + 1) % 360
        image = original_image.rotate(angle)
        image_width, image_height = image.size

        surface = SDL_CreateRGBSurfaceFrom(image.tostring(),
            image_width, image_height, 32, image_width * 4,
        SDL_BlitSurface(surface, None, screen, None)
        SDL_UpdateRect(screen, 0, 0, 0, 0)

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.