From 38f55cef0f4b83a2e169d78fa1cd6a187e07840e Mon Sep 17 00:00:00 2001 From: Chris Ball Date: Sat, 22 Dec 2007 00:26:33 +0000 Subject: Add "slideshow" example with "query" library function. --- (limited to 'data') diff --git a/data/graphics/slideshow b/data/graphics/slideshow new file mode 100644 index 0000000..225c1a4 --- /dev/null +++ b/data/graphics/slideshow @@ -0,0 +1,64 @@ +# image: take a picture + +import gst, pippy, pygame, sys, time +from random import * + +# XO screen is 1200 by 900 +size = width, height = 1200, 900 + +# grey background +bgcolor = (128,128,128) + +# Create a search dict +search = {} +search["mime_type"] = "image/jpeg" + +from pippy import query + +# Perform the search and retrieve the jobjects +results = query.find(search) +# XXX: Fix caching limit in query.py +objects = results.read(15) + +if len(objects) == 0: + print "No photos found." + time.sleep(3) + sys.exit() + +def get_image(): + for jobject in objects: + yield jobject.get_file_path() + +next_image = get_image() + +# pygame always needs to be initialized as the first call +pygame.init() + +# turn off cursor +pygame.mouse.set_visible(False) + +# create the pygame window at the desired size and return a Surface object for +# drawing in that window. +screen = pygame.display.set_mode(size) + +# load in previously grabbed frame +image = pygame.image.load(next_image.next()) + +while pippy.pygame.next_frame(): + for event in pygame.event.get(): + if event.type == pygame.QUIT: sys.exit() + elif event.type == pygame.KEYDOWN: + try: + image = pygame.image.load(next_image.next()) + except StopIteration: + sys.exit() + + # Scale up from 640x480 -> 1280x960 + newImage = pygame.transform.rotozoom(image, 0, 2.0) + newImageRect = newImage.get_rect() + newImageRect.centerx = screen.get_rect().centerx + newImageRect.centery = screen.get_rect().centery + + screen.fill(bgcolor) + screen.blit(newImage, newImageRect) + pygame.display.flip() \ No newline at end of file -- cgit v0.9.1