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)
| 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); |
no test coverage detected