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

Method write

ij/src/main/java/ij/io/TiffEncoder.java:110–147  ·  view source on GitHub ↗

Saves the image as a TIFF file. The OutputStream is not closed. The fi.pixels field must contain the image data. If fi.nImages>1 then fi.pixels must be a 2D array. The fi.offset field is ignored.

(OutputStream out)

Source from the content-addressed store, hash-verified

108 The fi.pixels field must contain the image data. If fi.nImages>1
109 then fi.pixels must be a 2D array. The fi.offset field is ignored. */
110 public void write(OutputStream out) throws IOException {
111 writeHeader(out);
112 long nextIFD = 0L;
113 if (fi.nImages>1)
114 nextIFD = imageOffset+stackSize;
115 boolean bigTiff = nextIFD+fi.nImages*ifdSize>=0xffffffffL;
116 if (bigTiff)
117 nextIFD = 0L;
118 writeIFD(out, (int)imageOffset, (int)nextIFD);
119 if (fi.fileType==FileInfo.RGB||fi.fileType==FileInfo.RGB48)
120 writeBitsPerPixel(out);
121 if (description!=null)
122 writeDescription(out);
123 if (scaleSize>0)
124 writeScale(out);
125 if (colorMapSize>0)
126 writeColorMap(out);
127 if (metaDataSize>0)
128 writeMetaData(out);
129 new ImageWriter(fi).write(out);
130 if (nextIFD>0L) {
131 int ifdSize2 = ifdSize;
132 if (metaDataSize>0) {
133 metaDataSize = 0;
134 nEntries -= 2;
135 ifdSize2 -= 2*12;
136 }
137 for (int i=2; i<=fi.nImages; i++) {
138 if (i==fi.nImages)
139 nextIFD = 0;
140 else
141 nextIFD += ifdSize2;
142 imageOffset += imageSize;
143 writeIFD(out, (int)imageOffset, (int)nextIFD);
144 }
145 } else if (bigTiff)
146 ij.IJ.log("Stack is larger than 4GB. Most TIFF readers will only open the first image. Use this information to open as raw:\n"+fi);
147 }
148
149 public void write(DataOutputStream out) throws IOException {
150 write((OutputStream)out);

Callers 4

saveAsTiffMethod · 0.95
saveAsTiffStackMethod · 0.95
serializeMethod · 0.95
saveAsZipMethod · 0.95

Calls 9

writeHeaderMethod · 0.95
writeIFDMethod · 0.95
writeBitsPerPixelMethod · 0.95
writeDescriptionMethod · 0.95
writeScaleMethod · 0.95
writeColorMapMethod · 0.95
writeMetaDataMethod · 0.95
writeMethod · 0.65
logMethod · 0.45

Tested by

no test coverage detected