From 434dbdefc4ceca1e63f331bd533f971a80deec8b Mon Sep 17 00:00:00 2001 From: Stephane Dallongeville <stephane.dallongeville@pasteur.fr> Date: Tue, 31 Aug 2021 18:17:03 +0200 Subject: [PATCH] Improved CallIJPlugin block so we don't require input ImagePlus --- .../adufour/blocks/tools/ij/CallIJPlugin.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/plugins/adufour/blocks/tools/ij/CallIJPlugin.java b/src/main/java/plugins/adufour/blocks/tools/ij/CallIJPlugin.java index 31330e0..e9b08f4 100644 --- a/src/main/java/plugins/adufour/blocks/tools/ij/CallIJPlugin.java +++ b/src/main/java/plugins/adufour/blocks/tools/ij/CallIJPlugin.java @@ -24,19 +24,23 @@ public class CallIJPlugin extends Plugin implements IJBlock { try { - IJ.run(varIp.getValue(true), pluginName.getValue(true), pluginParams.getValue(true)); + ImagePlus imgPlus = varIp.getValue(false); + String params = pluginParams.getValue(false); + + if (imgPlus != null) + IJ.run(imgPlus, pluginName.getValue(true), params); + else + IJ.run(pluginName.getValue(true), params); + // Set the output image (if available) with the following priority - ImagePlus output = WindowManager.getCurrentImage(); + ImagePlus output = IJ.getImage(); + // Default to the current "temporary" image (if any) if (output == null) - { - // Default to the current "temporary" image (if any) output = WindowManager.getTempCurrentImage(); - } + // Default to the input image (may have been modified "in-place" if (output == null) - { - // Default to the input image (may have been modified "in-place" output = varIp.getValue(); - } + varActiveIP.setValue(output); } catch (RuntimeException e) -- GitLab