(String path)
| 819 | } |
| 820 | |
| 821 | @AstroImageJ(reason = "Open pngs in zip as folder", modified = true) |
| 822 | public static ImagePlus openUsingImageIO(String path) { |
| 823 | ImagePlus imp = null; |
| 824 | BufferedImage img = null; |
| 825 | File f = new File(path); |
| 826 | try { |
| 827 | img = getImageFromPath(path); |
| 828 | } catch (Exception e) { |
| 829 | IJ.error("Open Using ImageIO", ""+e); |
| 830 | } |
| 831 | if (img==null) |
| 832 | return null; |
| 833 | if (IJ.debugMode) IJ.log("type="+img.getType()+", alpha="+img.getColorModel().hasAlpha()+", bands="+img.getSampleModel().getNumBands()); |
| 834 | boolean custom8Bit = img.getType()==0 && img.getSampleModel().getDataType()==0; |
| 835 | if (img.getColorModel().hasAlpha() || custom8Bit) { |
| 836 | int width = img.getWidth(); |
| 837 | int height = img.getHeight(); |
| 838 | BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); |
| 839 | Graphics g = bi.getGraphics(); |
| 840 | g.setColor(Color.white); |
| 841 | g.fillRect(0,0,width,height); |
| 842 | g.drawImage(img, 0, 0, null); |
| 843 | img = bi; |
| 844 | } |
| 845 | imp = new ImagePlus(f.getName(), img); |
| 846 | if (imp.getBitDepth()==16 && imp.getStackSize()>1) |
| 847 | imp = new CompositeImage(imp, IJ.COMPOSITE); |
| 848 | FileInfo fi = new FileInfo(); |
| 849 | fi.fileFormat = fi.IMAGEIO; |
| 850 | fi.fileName = f.getName(); |
| 851 | String parent = f.getParent(); |
| 852 | if (parent!=null) |
| 853 | fi.directory = parent + File.separator; |
| 854 | imp.setFileInfo(fi); |
| 855 | return imp; |
| 856 | } |
| 857 | |
| 858 | /** |
| 859 | * Get image from the path. If it is in a zip file, it will open the zip |
no test coverage detected