readme file, help
[imago.git] / im_debug.py
1 try:
2     import pygame
3     import Image
4 except ImportError, msg:
5     import sys
6     print >>sys.stderr, msg
7     sys.exit(1)
8
9 def show(image, caption=''):
10     if image.mode != 'RGB':
11         image = image.convert('RGB')
12     pygame.init()
13     if caption:
14         caption = "Imago: " + caption
15     else:
16         caption = "Imago"
17     pygame.display.set_caption(caption)
18     pygame.display.set_mode(image.size)
19     main_surface = pygame.display.get_surface()
20     picture = pygame.image.frombuffer(image.tostring(), image.size, image.mode)
21     main_surface.blit(picture, (0, 0))
22     pygame.display.update()
23     while True:
24         events = pygame.event.get()
25         for event in events:
26             if event.type == pygame.QUIT or event.type == pygame.KEYDOWN:
27                 pygame.quit()
28                 return