()
| 811 | } |
| 812 | |
| 813 | public FileInfo[] getTiffInfo() throws IOException { |
| 814 | long ifdOffset; |
| 815 | ArrayList list = new ArrayList(); |
| 816 | if (in==null) |
| 817 | in = new RandomAccessStream(new RandomAccessFile(new File(directory+name), "r")); |
| 818 | ifdOffset = OpenImageFileHeader(); |
| 819 | if (ifdOffset<0L) { |
| 820 | in.close(); |
| 821 | return null; |
| 822 | } |
| 823 | if (debugMode) dInfo = "\n " + name + ": opening\n"; |
| 824 | while (ifdOffset>0L) { |
| 825 | in.seek(ifdOffset); |
| 826 | FileInfo fi = OpenIFD(); |
| 827 | if (fi!=null) { |
| 828 | list.add(fi); |
| 829 | ifdOffset = ((long)getInt())&0xffffffffL; |
| 830 | } else |
| 831 | ifdOffset = 0L; |
| 832 | if (debugMode && ifdCount<10) dInfo += "nextIFD=" + ifdOffset + "\n"; |
| 833 | if (fi!=null && fi.nImages>1) |
| 834 | ifdOffset = 0L; // ignore extra IFDs in ImageJ and NIH Image stacks |
| 835 | } |
| 836 | if (list.size()==0) { |
| 837 | in.close(); |
| 838 | return null; |
| 839 | } else { |
| 840 | FileInfo[] info = (FileInfo[])list.toArray(new FileInfo[list.size()]); |
| 841 | if (debugMode) info[0].debugInfo = dInfo; |
| 842 | if (url!=null) { |
| 843 | in.seek(0); |
| 844 | info[0].inputStream = in; |
| 845 | } else |
| 846 | in.close(); |
| 847 | if (info[0].info==null) |
| 848 | info[0].info = tiffMetadata; |
| 849 | FileInfo fi = info[0]; |
| 850 | if (fi.fileType==FileInfo.GRAY16_UNSIGNED && fi.description==null) |
| 851 | fi.lutSize = 0; // ignore troublesome non-ImageJ 16-bit LUTs |
| 852 | if (debugMode) { |
| 853 | int n = info.length; |
| 854 | fi.debugInfo += "number of IFDs: "+ n + "\n"; |
| 855 | fi.debugInfo += "offset to first image: "+fi.getOffset()+ "\n"; |
| 856 | fi.debugInfo += "gap between images: "+getGapInfo(info) + "\n"; |
| 857 | fi.debugInfo += "little-endian byte order: "+fi.intelByteOrder + "\n"; |
| 858 | } |
| 859 | return info; |
| 860 | } |
| 861 | } |
| 862 | |
| 863 | String getGapInfo(FileInfo[] fi) { |
| 864 | if (fi.length<2) return "0"; |
no test coverage detected