Appends the data of the current image to the end of the file specified by path.
(String path, ImageProcessor ip)
| 603 | * Appends the data of the current image to the end of the file specified by path. |
| 604 | */ |
| 605 | void writeData(String path, ImageProcessor ip) { |
| 606 | int w = ip.getWidth(); |
| 607 | int h = ip.getHeight(); |
| 608 | if (ip instanceof ByteProcessor) { |
| 609 | byte[] pixels = (byte[])ip.getPixels(); |
| 610 | try { |
| 611 | DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path,true))); |
| 612 | for (int i = h - 1; i >= 0; i-- ) |
| 613 | for (int j = i*w; j < w*(i+1); j++) |
| 614 | dos.writeByte(pixels[j]); |
| 615 | dos.close(); |
| 616 | } catch (IOException e) { |
| 617 | IJ.showStatus("Error writing file!"); |
| 618 | return; |
| 619 | } |
| 620 | } else if (ip instanceof ShortProcessor) { |
| 621 | short[] pixels = (short[])ip.getPixels(); |
| 622 | try { |
| 623 | DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path,true))); |
| 624 | for (int i = h - 1; i >= 0; i-- ) |
| 625 | for (int j = i*w; j < w*(i+1); j++) |
| 626 | dos.writeShort(pixels[j]^0x8000); |
| 627 | dos.close(); |
| 628 | } catch (IOException e) { |
| 629 | IJ.showStatus("Error writing file!"); |
| 630 | return; |
| 631 | } |
| 632 | } else if (ip instanceof FloatProcessor) { |
| 633 | float[] pixels = (float[])ip.getPixels(); |
| 634 | try { |
| 635 | DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path,true))); |
| 636 | for (int i = h - 1; i >= 0; i-- ) |
| 637 | for (int j = i*w; j < w*(i+1); j++) |
| 638 | dos.writeFloat(pixels[j]); |
| 639 | dos.close(); |
| 640 | } catch (IOException e) { |
| 641 | IJ.showStatus("Error writing file!"); |
| 642 | return; |
| 643 | } |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | /** |
| 648 | * Extracts the original FITS header from the Properties object of the |
no test coverage detected