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

Method writeImage

ij/src/main/java/ij/plugin/PNG_Writer.java:50–65  ·  view source on GitHub ↗
(ImagePlus imp, String path, int transparentIndex)

Source from the content-addressed store, hash-verified

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();

Callers 1

runMethod · 0.95

Calls 15

write16gsMethod · 0.95
getHideOverlayMethod · 0.80
tempOverlayMethod · 0.80
isCompositeMethod · 0.80
isDefaultLutMethod · 0.80
getTypeMethod · 0.65
writeMethod · 0.65
duplicateMethod · 0.45
convertToRGBMethod · 0.45
getStackSizeMethod · 0.45

Tested by

no test coverage detected