changeset 94:6e74d45ea620

More work towards jpeg/png image export/import.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 06 Jul 2018 01:05:31 +0300
parents aadcd5f7e9dc
children 517348a7b543
files exporters.pde multipaint.pde
diffstat 2 files changed, 23 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/exporters.pde	Fri Jul 06 00:45:31 2018 +0300
+++ b/exporters.pde	Fri Jul 06 01:05:31 2018 +0300
@@ -1214,30 +1214,24 @@
 }
 
 
-PImage mpRenderImageWithBorder()
+PImage mpRenderImage(bool border)
 {
-    //output the visible graphics as image
-    //with border
-    //processing style
-    PImage output = createImage(
-        X * g_omag + g_bordh * g_omag,
-        Y * g_omag + g_bordv * g_omag,
-        RGB);
-
-    mpRenderToImageAt(output, int((g_bordh * g_omag) / 2), int((g_bordv * g_omag) / 2));
+    PImage output;
 
-    return output;
-}
-
+    if (border)
+    {
+        pimage = createImage(
+            X * g_omag + g_bordh * g_omag,
+            Y * g_omag + g_bordv * g_omag,
+            RGB);
 
-PImage mpRenderImageWithoutBorder()
-{
-    //output the visible graphics as image
-    //processing style
-    //without border
-    PImage output = createImage(X * g_omag, Y * g_omag, RGB);
-
-    mpRenderToImageAt(output, 0, 0);
+        mpRenderToImageAt(output, int((g_bordh * g_omag) / 2), int((g_bordv * g_omag) / 2));
+    }
+    else
+    {
+        output = createImage(X * g_omag, Y * g_omag, RGB);
+        mpRenderToImageAt(output, 0, 0);
+    }
 
     return output;
 }
--- a/multipaint.pde	Fri Jul 06 00:45:31 2018 +0300
+++ b/multipaint.pde	Fri Jul 06 01:05:31 2018 +0300
@@ -311,15 +311,16 @@
 }
 
 
-void mpSavePNGImage(String name)
+void mpSavePNGImage(String name, int fmt, bool border)
 {
-    PImage simg;
-    if (g_data[int('Q')] == 0)
-        simg = mpRenderImageWithoutBorder();
-    else
-        simg = mpRenderImageWithBorder();
+    PImage simg = mpRenderImage(border);
+//    if (g_data[int('Q')] == 0)
 
-    // XXX TODO .. actually save the image
+    if (simg !== null)
+    {
+        // XXX TODO .. actually save the image, something like ..
+        //simg.canvas.toBlob(function(idata){ mpSaveBinaryFile(name, idata); }, "image/png", 0.95);
+    }
 }