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

Method run

ij/src/main/java/ij/plugin/PNG_Writer.java:21–48  ·  view source on GitHub ↗
(String path)

Source from the content-addressed store, hash-verified

19 ImagePlus imp;
20
21 public void run(String path) {
22 imp = WindowManager.getCurrentImage();
23 if (imp==null) {
24 IJ.noImage();
25 return;
26 }
27 if (path.equals("")) {
28 SaveDialog sd = new SaveDialog("Save as PNG...", imp.getTitle(), ".png");
29 String name = sd.getFileName();
30 if (name==null)
31 return;
32 String dir = sd.getDirectory();
33 path = dir + name;
34 }
35 try {
36 writeImage(imp, path, Prefs.getTransparentIndex());
37 } catch (Exception e) {
38 String msg = e.getMessage();
39 if (msg==null || msg.equals(""))
40 msg = ""+e;
41 msg = "An error occured writing the file.\n \n" + msg;
42 if (msg.contains("NullPointerException"))
43 msg = "Incorrect file path:";
44 msg += "\n \n"+path;
45 IJ.error("PNG Writer", msg);
46 }
47 IJ.showStatus("");
48 }
49
50 public void writeImage(ImagePlus imp, String path, int transparentIndex) throws Exception {
51 if (imp.getType()==ImagePlus.COLOR_256) {

Callers

nothing calls this directly

Calls 12

getCurrentImageMethod · 0.95
noImageMethod · 0.95
getFileNameMethod · 0.95
getDirectoryMethod · 0.95
writeImageMethod · 0.95
getTransparentIndexMethod · 0.95
errorMethod · 0.95
showStatusMethod · 0.95
getTitleMethod · 0.65
equalsMethod · 0.45
getMessageMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected