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

Method write

ij/src/main/java/ij/io/ImageWriter.java:272–320  ·  view source on GitHub ↗

Writes the image to the specified OutputStream. 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, for example an array of images returned by ImageStack.getImageArray()). The fi.offset field is ignored.

(OutputStream out)

Source from the content-addressed store, hash-verified

270 array of images returned by ImageStack.getImageArray()).
271 The fi.offset field is ignored. */
272 public void write(OutputStream out) throws IOException {
273 if (fi.pixels==null && fi.virtualStack==null)
274 throw new IOException("ImageWriter: fi.pixels==null");
275 if (fi.nImages>1 && fi.virtualStack==null && !(fi.pixels instanceof Object[]))
276 throw new IOException("ImageWriter: fi.pixels not a stack");
277 if (fi.width*fi.height*fi.getBytesPerPixel()<26214400)
278 showProgressBar = false; // don't show progress bar if image<25MB
279 switch (fi.fileType) {
280 case FileInfo.GRAY8:
281 case FileInfo.COLOR8:
282 if (fi.nImages>1 && fi.virtualStack!=null)
283 write8BitVirtualStack(out, fi.virtualStack);
284 else if (fi.nImages>1)
285 write8BitStack(out, (Object[])fi.pixels);
286 else
287 write8BitImage(out, (byte[])fi.pixels);
288 break;
289 case FileInfo.GRAY16_SIGNED:
290 case FileInfo.GRAY16_UNSIGNED:
291 if (fi.nImages>1 && fi.virtualStack!=null)
292 write16BitVirtualStack(out, fi.virtualStack);
293 else if (fi.nImages>1)
294 write16BitStack(out, (Object[])fi.pixels);
295 else
296 write16BitImage(out, (short[])fi.pixels);
297 break;
298 case FileInfo.RGB48:
299 writeRGB48Image(out, (Object[])fi.pixels);
300 break;
301 case FileInfo.GRAY32_FLOAT:
302 if (fi.nImages>1 && fi.virtualStack!=null)
303 writeFloatVirtualStack(out, fi.virtualStack);
304 else if (fi.nImages>1)
305 writeFloatStack(out, (Object[])fi.pixels);
306 else
307 writeFloatImage(out, (float[])fi.pixels);
308 break;
309 case FileInfo.RGB:
310 if (fi.nImages>1 && fi.virtualStack!=null)
311 writeRGBVirtualStack(out, fi.virtualStack);
312 else if (fi.nImages>1)
313 writeRGBStack(out, (Object[])fi.pixels);
314 else
315 writeRGBImage(out, (int[])fi.pixels);
316 break;
317 default:
318 }
319 savingStack = false;
320 }
321
322}
323

Callers 4

saveAsJpegMethod · 0.95
saveAsRawMethod · 0.95
saveAsRawStackMethod · 0.95
saveAsLutMethod · 0.95

Calls 14

write8BitVirtualStackMethod · 0.95
write8BitStackMethod · 0.95
write8BitImageMethod · 0.95
write16BitStackMethod · 0.95
write16BitImageMethod · 0.95
writeRGB48ImageMethod · 0.95
writeFloatStackMethod · 0.95
writeFloatImageMethod · 0.95
writeRGBVirtualStackMethod · 0.95
writeRGBStackMethod · 0.95

Tested by

no test coverage detected