StarSuite 6
StarSuite のアカデミック版が出ました.
4,000円と安いので,講座でも買ってもらおうと思います.
少しずつ Microsoft Office 離れを開始.
Java
Tag 情報ファイルを読み込んで,Tiff の IDF tag を解析(IDF tag 名のみ)するコードを書く.
class を使ってみる.
import java.io.*; import java.lang.*; class TiffTag { String [][] key = new String[80][6]; int i = 0, j = 0; int MaxNumberOfTag = 0; String Data(int i, int j) { return (key [i][j]); } int Number() { return (MaxNumberOfTag); } void LoadTaggFile( String args ) { try { FileReader File = new FileReader(args); int a; key [i][j] = ""; // 次の配列を初期化 String s; while(( a = File.read() ) != -1 ) { if (a == '\n') { s = key [i][0]; for (int k = 1; k <= j; k++) { s += "\t" + key [i][k] ; } // System.out.print( s + "\n" ); i++; j = 0; key [i][j] = ""; // 次の配列を初期化 } else if (a == '\t') { j++; key [i][j] = ""; // 次の配列を初期化 } else { key [i][j] += (char) a; } } MaxNumberOfTag = i; File.close(); } catch ( Exception errorvalue ) { errorvalue.printStackTrace(); } } } class readtiff { static String Byte2HexStr(int a) { StringBuffer sb= new StringBuffer(); if (a >= 0x10) { sb.append(Integer.toHexString(a)); } else { sb.append("0" + Integer.toHexString(a)); } return sb.toString().toUpperCase(); } static String Byte4DecStr(int a) { StringBuffer sb= new StringBuffer(); if (a >= 1000) { sb.append(Integer.toHexString(a)); } else if (a >= 100) { sb.append("0" + a); } else if (a >= 10) { sb.append("00" + a); } else { sb.append("000" + a); } return sb.toString(); } public static void main( String args[] ) { try { // tag file の読み込み TiffTag IDF = new TiffTag(); IDF.LoadTaggFile("tags.txt"); //FileInputStream File = new FileInputStream(args[0]); FileInputStream File = new FileInputStream("h69r-01.tiff"); int TempByte, TempByteA, TempByteB; int StreamHeader = 0; String TempStr = ""; // tiff header の読み込み System.out.print(Byte4DecStr(StreamHeader) + ": "); for (int i = 0; i < 8; i++) { TempByte = File.read(); System.out.print(Byte2HexStr(TempByte)+" "); StreamHeader += 1; } System.out.print("\n"); // IDF の個数を読み込み System.out.print(Byte4DecStr(StreamHeader) + ": "); int NumberofIDF; NumberofIDF = File.read(); TempByte = File.read(); System.out.print(Byte2HexStr(NumberofIDF) + " " + Byte2HexStr(TempByte) + " "); NumberofIDF = TempByte * 256 + NumberofIDF; System.out.println(" / " + (int) NumberofIDF + " of IDF"); StreamHeader += 2; // IDF を読み込み for (int i = 0; i < NumberofIDF; i++) { System.out.print(Byte4DecStr(StreamHeader) + ": "); TempByteB = File.read(); System.out.print(Byte2HexStr(TempByteB)+" "); TempByteA = File.read(); System.out.print(Byte2HexStr(TempByteA)+" "); TempStr = "(unknown)"; for (int j = 1; j < IDF.Number(); j++) { if ( Integer.valueOf(IDF.Data(j, 1)).intValue() == TempByteA * 256 + TempByteB) { TempStr = IDF.Data(j, 0); } } StreamHeader += 2; for (int j = 0; j < 10; j++) { TempByteA = File.read(); System.out.print(Byte2HexStr(TempByteA)+" "); StreamHeader += 1; } System.out.print("/ " + TempStr + "\n"); } // IDF の終わり System.out.print(Byte4DecStr(StreamHeader) + ": "); for (int i = 0; i < 4; i++) { TempByte = File.read(); System.out.print(Byte2HexStr(TempByte)+" "); StreamHeader += 1; } System.out.print("\n"); File.close(); } catch ( Exception errorvalue ) { errorvalue.printStackTrace(); } } }