Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2011-02-07 14:05:17 (GMT)
committer Walter Bender <walter@sugarlabs.org>2011-02-07 14:05:17 (GMT)
commit0f6ec143612b29306e20b0512a8b1ea3b2cb7662 (patch)
treec8be9298a63a252cb228860d123c9f2617c58f83
parent050957fe8e2d62d5d89a538c5750edd90900ab29 (diff)
trying base64 for draw_pixbuf sharing
-rw-r--r--TurtleArt/tacanvas.py15
-rw-r--r--TurtleArt/tacollaboration.py17
-rw-r--r--TurtleArt/tautils.py2
3 files changed, 21 insertions, 13 deletions
diff --git a/TurtleArt/tacanvas.py b/TurtleArt/tacanvas.py
index 8f12f61..952fc25 100644
--- a/TurtleArt/tacanvas.py
+++ b/TurtleArt/tacanvas.py
@@ -501,21 +501,22 @@ class TurtleGraphics:
y, w, h, path, image_to_base64(pixbuf,
get_path(self.tw.activity, 'instance')))
else:
+ # Outside of Sugar, we save a path
self.tw.svg_string += self.svg.image(x - self.width / 2,
y, w, h, path)
if self.tw.sharing():
- data = pixbuf.get_pixels()
+ if self.tw.running_sugar:
+ tmp_path = get_path(self.tw.activity, 'instance')
+ else:
+ tmp_path = '/tmp'
+ data = image_to_base64(pixbuf, tmp_path)
height = pixbuf.get_height()
width = pixbuf.get_width()
- stride = pixbuf.get_rowstride()
- bits_per_sample = pixbuf.get_bits_per_sample()
- has_alpha = pixbuf.get_has_alpha()
- colorspace = pixbuf.get_colorspace()
event = "P|%s" % (data_to_string([self._get_my_nick(),
[round_int(a), round_int(b), round_int(x), round_int(y),
round_int(w), round_int(h),
- width, height, stride, bits_per_sample,
- has_alpha, colorspace, data]]))
+ round_int(width), round_int(height),
+ data]]))
self._send_event(event, share)
def draw_text(self, label, x, y, size, w, share=True):
diff --git a/TurtleArt/tacollaboration.py b/TurtleArt/tacollaboration.py
index 0bebe67..83ce835 100644
--- a/TurtleArt/tacollaboration.py
+++ b/TurtleArt/tacollaboration.py
@@ -225,13 +225,18 @@ class Collaboration():
def _draw_pixbuf(self, payload):
if len(payload) > 0:
- [nick, [a, b, x, y, w, h, width, height, stride,
- bits_per_sample, has_alpha, colorspace, data]] =\
- data_from_string(payload)
+ [nick, [a, b, x, y, w, h, width, height, data]] =\
+ data_from_string(payload)
if nick != self._tw.nick:
- self._tw.canvas.draw_pixbuf(gtk.gdk.pixbuf_new_from_data(
- data, colorspace, has_alpha, bits_per_sample, width,
- height, stride), a, b, x, y, w, h, None, False)
+ if self.tw.running_sugar:
+ tmp_path = get_path(self.tw.activity, 'instance')
+ else:
+ tmp_path = '/tmp'
+ file_name = base64_to_image(data, tmp_path)
+ pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(file_name,
+ width, height)
+ self._tw.canvas.draw_pixbuf(pixbuf, a, b, x, y, w, h,
+ file_name, False)
def _move_forward(self, payload):
if len(payload) > 0:
diff --git a/TurtleArt/tautils.py b/TurtleArt/tautils.py
index db2ef4b..2b7b230 100644
--- a/TurtleArt/tautils.py
+++ b/TurtleArt/tautils.py
@@ -296,6 +296,7 @@ def image_to_base64(pixbuf, path_name):
file_handle = open(base64, 'r')
data = file_handle.read()
file_handle.close()
+ print 'image to base64:' + file_name
return data
@@ -308,6 +309,7 @@ def base64_to_image(data, path_name):
file_name = os.path.join(path_name, 'imagetmp.png')
cmd = "base64 -d <" + base64 + ">" + file_name
subprocess.check_call(cmd, shell=True)
+ print 'base64 to image:' + file_name
return file_name