Open main menu
Home
Random
Log in
Settings
About Sugar Labs
Disclaimers
Sugar Labs
Search
Changes
← Older edit
Newer edit →
Features/GTK3/Porting
(view source)
Revision as of 21:55, 9 November 2011
726 bytes added
,
21:55, 9 November 2011
no edit summary
Line 144:
Line 144:
* Notes from the TurtleArt conversion
* Notes from the TurtleArt conversion
* Removing Hippo
* Removing Hippo
+
+
===Taking a screenshot and making a thumbnail===
+
To make a screenshot of the window:
+
<pre>
+
width, height = window.get_width(), window.get_height()
+
thumb_surface = Gdk.Window.create_similar_surface(window,
+
cairo.CONTENT_COLOR,
+
width, height)
+
+
thumb_width, thumb_height = style.zoom(100), style.zoom(80)
+
cairo_context = cairo.Context(thumb_surface)
+
thumb_scale_w = thumb_width * 1.0 / width
+
thumb_scale_h = thumb_height * 1.0 / height
+
cairo_context.scale(thumb_scale_w, thumb_scale_h)
+
Gdk.cairo_set_source_window(cairo_context, window, 0, 0)
+
cairo_context.paint()
+
thumb_surface.write_to_png(png_path_or_filelike_object)
+
</pre>
Manuq
296
edits