(ImagePlus imp, String path, int transparentIndex)
| 48 | } |
| 49 | |
| 50 | public void writeImage(ImagePlus imp, String path, int transparentIndex) throws Exception { |
| 51 | if (imp.getType()==ImagePlus.COLOR_256) { |
| 52 | imp = imp.duplicate(); |
| 53 | new ImageConverter(imp).convertToRGB(); |
| 54 | } |
| 55 | if (imp.getStackSize()==4 && imp.getBitDepth()==8 && "alpha".equalsIgnoreCase(imp.getStack().getSliceLabel(4))) |
| 56 | writeFourChannelsWithAlpha(imp, path); |
| 57 | else if (transparentIndex>=0 && transparentIndex<=255 && imp.getBitDepth()==8) |
| 58 | writeImageWithTransparency(imp, path, transparentIndex); |
| 59 | else if (imp.getOverlay()!=null && !imp.getHideOverlay() && !imp.tempOverlay()) |
| 60 | ImageIO.write(imp.flatten().getBufferedImage(), "png", new File(path)); |
| 61 | else if (imp.getBitDepth()==16 && !imp.isComposite() && imp.getProcessor().isDefaultLut()) |
| 62 | write16gs(imp, path); |
| 63 | else |
| 64 | ImageIO.write(imp.getBufferedImage(), "png", new File(path)); |
| 65 | } |
| 66 | |
| 67 | private void writeFourChannelsWithAlpha(ImagePlus imp, String path) throws Exception { |
| 68 | ImageStack stack = imp.getStack(); |
no test coverage detected