Mercurial > hg > forks > multipaint-js
changeset 202:06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
It is a bit difficult to trigger, though. Will have to explore better
ways later.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 29 Aug 2018 14:10:11 +0300 |
parents | 823672f83ae9 |
children | b7c7b13b46c2 |
files | events.pde |
diffstat | 1 files changed, 18 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/events.pde Wed Aug 29 14:08:05 2018 +0300 +++ b/events.pde Wed Aug 29 14:10:11 2018 +0300 @@ -955,7 +955,8 @@ message("ERROR!"); } - if (g_data[int('E')] == 1) { + if (g_data[int('E')] == 1) + { g_data[int('E')] = 0; // message("Export SRC|is disabled"); @@ -1006,7 +1007,22 @@ if (g_data[int('W')] == 1) { g_data[int('W')] = 0; - if (g_formatext != "") { + + if (g_control) + { + message("PNG|export"); + + String fname = filename +"_"+ (g_spare ? "spare" : "main") +".png"; + PImage simg = mpRenderImage(true, 64, 32, 1); + + if (simg !== null) + { + simg.sourceImg.toBlob(function(idata){ mpSaveBinaryBlob(fname, idata); }, "image/png", 0.95); + } + } + else + if (g_formatext != "") + { message("Format|export"); String fname = filename +"_"+ (g_spare ? "spare" : "main") +"."+ g_formatext;