diff options
author | Ignacio Rodriguez <ignacio@sugarlabs.org> | 2013-12-13 18:48:53 (GMT) |
---|---|---|
committer | Ignacio Rodriguez <ignacio@sugarlabs.org> | 2013-12-13 18:48:53 (GMT) |
commit | 5b7ccbfca2b051fba7d8cace5112feb3232adc89 (patch) | |
tree | a4a96700e4e29f76c62b4bf25f99e9f597c36568 /activity.py | |
parent | 3085b496e00efe8e889485134e3131ce0a94c703 (diff) |
add mechanism for save preview
Diffstat (limited to 'activity.py')
-rw-r--r-- | activity.py | 22 |
1 files changed, 1 insertions, 21 deletions
diff --git a/activity.py b/activity.py index 0d905ba..1e45d26 100644 --- a/activity.py +++ b/activity.py @@ -91,27 +91,7 @@ class PhysicsActivity(activity.Activity): self.game.write_file(file_path) def get_preview(self): - """ Custom preview code to get image from pygame. """ - if self.preview: - return self.preview - surface = pygame.display.get_surface() - width, height = surface.get_width(), surface.get_height() - string_surface = pygame.image.tostring(surface, "RGB") - pixbuf = GdkPixbuf.Pixbuf.new_from_data(string_surface, - GdkPixbuf.Colorspace.RGB, 0, 8, - width, height, - 3 * width) - pixbuf = pixbuf.scale_simple(300, 225, GdkPixbuf.InterpType.BILINEAR) - - preview_data = [] - - def save_func(buf, data): - data.append(buf) - - pixbuf.save_to_callback(save_func, 'png', user_data=preview_data) - preview_data = ''.join(preview_data) - - return preview_data + return self._canvas.get_preview() def build_toolbar(self): self.max_participants = 1 |