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