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

Method saveAsRawStack

ij/src/main/java/ij/io/FileSaver.java:530–574  ·  view source on GitHub ↗

Save the stack as raw data using the specified path.

(String path)

Source from the content-addressed store, hash-verified

528
529 /** Save the stack as raw data using the specified path. */
530 public boolean saveAsRawStack(String path) {
531 if (fi.nImages==1)
532 {IJ.log("This is not a stack"); return false;}
533 fi.intelByteOrder = Prefs.intelByteOrder;
534 boolean signed16Bit = false;
535 Object[] stack = null;
536 int n = 0;
537 boolean virtualStack = imp.getStackSize()>1 && imp.getStack().isVirtual();
538 if (virtualStack) {
539 fi.virtualStack = (VirtualStack)imp.getStack();
540 if (imp.getProperty("AnalyzeFormat")!=null) fi.fileName="FlipTheseImages";
541 }
542 OutputStream out = null;
543 try {
544 signed16Bit = imp.getCalibration().isSigned16Bit();
545 if (signed16Bit && !virtualStack) {
546 stack = (Object[])fi.pixels;
547 n = imp.getWidth()*imp.getHeight();
548 for (int slice=0; slice<fi.nImages; slice++) {
549 short[] pixels = (short[])stack[slice];
550 for (int i=0; i<n; i++)
551 pixels[i] = (short)(pixels[i]-32768);
552 }
553 }
554 ImageWriter file = new ImageWriter(fi);
555 out = new BufferedOutputStream(new FileOutputStream(path),bsize);
556 file.write(out);
557 out.close();
558 } catch (IOException e) {
559 showErrorMessage("saveAsRawStack", path, e);
560 return false;
561 } finally {
562 if (out!=null)
563 try {out.close();} catch (IOException e) {}
564 }
565 if (signed16Bit) {
566 for (int slice=0; slice<fi.nImages; slice++) {
567 short[] pixels = (short[])stack[slice];
568 for (int i=0; i<n; i++)
569 pixels[i] = (short)(pixels[i]+32768);
570 }
571 }
572 updateImp(fi, fi.RAW);
573 return true;
574 }
575
576 /** Save the image as comma or tab-delimited text using a save
577 file dialog. Returns false if the user selects cancel. */

Callers 1

saveAsRawMethod · 0.95

Calls 13

logMethod · 0.95
writeMethod · 0.95
showErrorMessageMethod · 0.95
updateImpMethod · 0.95
getCalibrationMethod · 0.80
closeMethod · 0.65
getStackSizeMethod · 0.45
isVirtualMethod · 0.45
getStackMethod · 0.45
getPropertyMethod · 0.45
isSigned16BitMethod · 0.45
getWidthMethod · 0.45

Tested by

no test coverage detected