diff options
author | Agustin Zubiaga <aguz@sugarlabs.org> | 2012-10-02 03:48:29 (GMT) |
---|---|---|
committer | Agustin Zubiaga <aguz@sugarlabs.org> | 2012-10-02 03:48:29 (GMT) |
commit | 03e5e85f43d973323e56073071e2ddf0c4dd46c9 (patch) | |
tree | e18c0d7b67dafbc96cd6233d98830a66679af471 | |
parent | ecb1f86526376bd8ddad004c50a157b1d0d2fb5b (diff) |
Center the image on the screen
Signed-off-by: Agustin Zubiaga <aguz@sugarlabs.org>
-rw-r--r-- | ImageView.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/ImageView.py b/ImageView.py index cbfa560..2785337 100644 --- a/ImageView.py +++ b/ImageView.py @@ -133,17 +133,13 @@ class ImageViewer(Gtk.DrawingArea): x = rect.x y = rect.y - if self.parent: - rect = self.parent.get_allocation() - if rect.width > w: - x = int(((rect.width - x) - w) / 2) - if rect.height > h: - y = int(((rect.height - y) - h) / 2) - - # TODO: center the image into the canvas - # ctx.translate(x, y) + rect = self.get_allocation() + if rect.width > w: + x = int((rect.width - w) / 2) + if rect.height > h: + y = int((rect.height - h) / 2) - ctx.set_source_surface(self.surface, 0, 0) + ctx.set_source_surface(self.surface, x, y) ctx.paint() logging.debug('ImageViewer.draw end %f', (time.time() - timeini)) |