diff options
author | Walter Bender <walter.bender@gmail.com> | 2011-11-07 12:41:25 (GMT) |
---|---|---|
committer | Walter Bender <walter.bender@gmail.com> | 2011-11-07 12:41:25 (GMT) |
commit | 19954624262f29605d689e7b038e14d4f80f71e8 (patch) | |
tree | d6d2cbf61a39ed9032723933f691e0020133da26 /TurtleArt | |
parent | 8d4816b0d98de58485e5ba5bdf78fa1c7a9ebdc0 (diff) |
more cases where I missed updating image_to_base64
Diffstat (limited to 'TurtleArt')
-rw-r--r-- | TurtleArt/tacanvas.py | 19 | ||||
-rw-r--r-- | TurtleArt/taexporthtml.py | 23 |
2 files changed, 24 insertions, 18 deletions
diff --git a/TurtleArt/tacanvas.py b/TurtleArt/tacanvas.py index 8474c87..83f6461 100644 --- a/TurtleArt/tacanvas.py +++ b/TurtleArt/tacanvas.py @@ -543,12 +543,16 @@ class TurtleGraphics: self.inval() if self.tw.saving_svg: if self.tw.running_sugar: - # In Sugar, we need to embed the images inside the SVG - self.tw.svg_string += self.svg.image(x - self.width / 2, - y, w, h, path, image_to_base64(pixbuf, - get_path(self.tw.activity, 'instance'))) + # In Sugar, we embed the images inside the SVG + tmp_file = os.path.join(get_path(tw.activity, 'instance'), + 'tmpfile.png') + pixbuf.save(tmp_file, 'png', {'quality': '100'}) + self.tw.svg_string += self.svg.image( + x - self.width / 2, y, w, h, path, + image_to_base64(tmp_file, + get_path(self.tw.activity, 'instance'))) else: - # Outside of Sugar, we save a path + # In GNOME, we embed a path self.tw.svg_string += self.svg.image(x - self.width / 2, y, w, h, path) if self.tw.sharing() and share: @@ -556,7 +560,10 @@ class TurtleGraphics: tmp_path = get_path(self.tw.activity, 'instance') else: tmp_path = '/tmp' - data = image_to_base64(pixbuf, tmp_path) + tmp_file = os.path.join(get_path(tw.activity, 'instance'), + 'tmpfile.png') + pixbuf.save(tmp_file, 'png', {'quality': '100'}) + data = image_to_base64(tmp_file, tmp_path) height = pixbuf.get_height() width = pixbuf.get_width() x, y = self.screen_to_turtle_coordinates(x, y) diff --git a/TurtleArt/taexporthtml.py b/TurtleArt/taexporthtml.py index 913e612..90dcc4d 100644 --- a/TurtleArt/taexporthtml.py +++ b/TurtleArt/taexporthtml.py @@ -78,43 +78,42 @@ def save_html(self, tw, embed_flag=True): """ htmlcode = '' if len(tw.saved_pictures) > 0: - for i, p in enumerate(tw.saved_pictures): + for i, image_file in enumerate(tw.saved_pictures): htmlcode += HTML_GLUE['slide'][0] + str(i) htmlcode += HTML_GLUE['slide'][1] + \ HTML_GLUE['div'][0] + \ HTML_GLUE['h1'][0] if embed_flag: - f = open(p, 'r') + f = open(image_file, 'r') imgdata = f.read() f.close() - if p.endswith(('.svg')): + if image_file.endswith(('.svg')): tmp = imgdata else: - pixbuf = gtk.gdk.pixbuf_new_from_file(p) - imgdata = image_to_base64(pixbuf, - get_path(tw.activity, 'instance')) + imgdata = image_to_base64(image_file, + get_path(tw.activity, 'instance')) tmp = HTML_GLUE['img2'][0] tmp += imgdata tmp += HTML_GLUE['img2'][1] else: - if p.endswith(('.svg')): - f = open(p, 'r') + if image_file.endswith(('.svg')): + f = open(image_file, 'r') imgdata = f.read() f.close() tmp = imgdata else: tmp = HTML_GLUE['img3'][0] - tmp += p + tmp += image_file tmp += HTML_GLUE['img3'][1] htmlcode += tmp + \ HTML_GLUE['h1'][1] + \ HTML_GLUE['div'][1] else: if embed_flag: - tmpfile = os.path.join(get_path(tw.activity, 'instance'), + tmp_file = os.path.join(get_path(tw.activity, 'instance'), 'tmpfile.png') - save_picture(self.tw.canvas, tmpfile) - imgdata = image_to_base64(tmpfile, + save_picture(self.tw.canvas, tmp_file) + imgdata = image_to_base64(tmp_file, get_path(tw.activity, 'instance')) else: imgdata = os.path.join(self.tw.load_save_folder, 'image') |