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

Method write

ij/src/main/java/ij/io/TextEncoder.java:29–59  ·  view source on GitHub ↗

Saves the image as a tab-delimited text file.

(DataOutputStream out)

Source from the content-addressed store, hash-verified

27
28 /** Saves the image as a tab-delimited text file. */
29 public void write(DataOutputStream out) throws IOException {
30 PrintWriter pw = new PrintWriter(out);
31 boolean calibrated = cal!=null && cal.calibrated();
32 if (calibrated)
33 ip.setCalibrationTable(cal.getCTable());
34 else
35 ip.setCalibrationTable(null);
36 boolean intData = !calibrated && ((ip instanceof ByteProcessor) || (ip instanceof ShortProcessor));
37 int width = ip.getWidth();
38 int height = ip.getHeight();
39 int inc = height/20;
40 if (inc<1) inc = 1;
41 //IJ.showStatus("Exporting as text...");
42 double value;
43 for (int y=0; y<height; y++) {
44 for (int x=0; x<width; x++) {
45 value = ip.getPixelValue(x,y);
46 if (intData)
47 pw.print((int)value);
48 else
49 pw.print(IJ.d2s(value, precision));
50 if (x!=(width-1))
51 pw.print(delimiter);
52 }
53 pw.println();
54 if (y%inc==0) IJ.showProgress((double)y/height);
55 }
56 pw.close();
57 IJ.showProgress(1.0);
58 //IJ.showStatus("");
59 }
60
61 public void setDelimiter(String delimiter) {
62 this.delimiter = delimiter;

Callers 1

saveAsTextMethod · 0.95

Calls 11

d2sMethod · 0.95
showProgressMethod · 0.95
calibratedMethod · 0.80
setCalibrationTableMethod · 0.80
getCTableMethod · 0.80
printlnMethod · 0.80
closeMethod · 0.65
getWidthMethod · 0.45
getHeightMethod · 0.45
getPixelValueMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected