MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / openUsingImageIO

Method openUsingImageIO

ij/src/main/java/ij/io/Opener.java:821–856  ·  view source on GitHub ↗
(String path)

Source from the content-addressed store, hash-verified

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

Callers 2

runMethod · 0.95
openImageMethod · 0.95

Calls 15

getImageFromPathMethod · 0.95
errorMethod · 0.95
logMethod · 0.95
getBitDepthMethod · 0.95
getStackSizeMethod · 0.95
setFileInfoMethod · 0.95
hasAlphaMethod · 0.80
getGraphicsMethod · 0.80
fillRectMethod · 0.80
getParentMethod · 0.80
getTypeMethod · 0.65
setColorMethod · 0.65

Tested by

no test coverage detected