001/*******************************************************************************
002 * Permission to use and distribute this software is granted under the BSD 2-Clause
003 * "Simplified" License (see http://opensource.org/licenses/BSD-2-Clause).
004 * Copyright (c) 2016-2023 Wilhelm Burger. All rights reserved.
005 * Visit https://imagingbook.com for additional details.
006 ******************************************************************************/
007package Calibration_Plugins_1;
008
009import ij.IJ;
010import ij.ImagePlus;
011import ij.plugin.PlugIn;
012import imagingbook.calibration.zhang.data.CalibrationImage;
013import imagingbook.core.jdoc.JavaDocHelp;
014import imagingbook.core.resource.ImageResource;
015
016/**
017 * Opens Zhang's standard calibration images as a stack of RGB images. The image data are stored as a resource in the
018 * local Java class tree. Also demonstrates the use of the resource access mechanism.
019 *
020 * @author WB
021 * @version 2021/08/22
022 */
023public class Open_Image_Stack implements PlugIn, JavaDocHelp {
024        
025        static ImageResource resource = CalibrationImage.CalibImageStack;
026
027        public void run(String args) {
028                
029                if (resource == null) {
030                        IJ.error("Could not find resource " + resource);
031                        return;
032                }
033                
034                // if (resource.isInsideJar())
035                //      IJ.log("Loading resources from JAR file: " + resource.getURL());
036                // else
037                //      IJ.log("Loading resources from regular file: " + resource.getURL());
038                
039                ImagePlus im = resource.getImagePlus();
040                if (im != null) {
041                        im.show();
042                }
043                else {
044                        IJ.error("Could not open image " + resource);
045                }
046        }
047        
048}