From e9cbc72728260ae120ddda4384f1333993f247c4 Mon Sep 17 00:00:00 2001
From: Stephane Dallongeville <stephane.dallongeville@pasteur.fr>
Date: Tue, 31 Aug 2021 18:17:17 +0200
Subject: [PATCH] Added new GetActiveImagePlus block

---
 .../blocks/tools/ij/GetActiveImagePlus.java   | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 src/main/java/plugins/adufour/blocks/tools/ij/GetActiveImagePlus.java

diff --git a/src/main/java/plugins/adufour/blocks/tools/ij/GetActiveImagePlus.java b/src/main/java/plugins/adufour/blocks/tools/ij/GetActiveImagePlus.java
new file mode 100644
index 0000000..f5fe702
--- /dev/null
+++ b/src/main/java/plugins/adufour/blocks/tools/ij/GetActiveImagePlus.java
@@ -0,0 +1,37 @@
+package plugins.adufour.blocks.tools.ij;
+
+import icy.plugin.abstract_.Plugin;
+import ij.IJ;
+import ij.ImagePlus;
+import ij.WindowManager;
+import plugins.adufour.blocks.util.VarList;
+import plugins.adufour.vars.lang.VarImagePlus;
+
+public class GetActiveImagePlus extends Plugin implements IJBlock
+{
+    VarImagePlus ip = new VarImagePlus("ImagePlus", null);
+
+    @Override
+    public void declareInput(VarList inputMap)
+    {
+        //
+    }
+
+    @Override
+    public void declareOutput(VarList outputMap)
+    {
+        outputMap.add("ImagePlus", ip);
+    }
+
+    @Override
+    public void run()
+    {
+        // Set the output image (if available) with the following priority
+        ImagePlus imgPlus = IJ.getImage();
+        // Default to the current "temporary" image (if any)
+        if (imgPlus == null)
+            imgPlus = WindowManager.getTempCurrentImage();
+
+        ip.setValue(imgPlus);
+    }
+}
-- 
GitLab