2016-07-20 24 views
-1

Tiffファイルを別のイメージに変換するJavaプログラムを作成していますが、TIFFファイルにII *が含まれていないためImageDecoderを使用できません私のtiffファイルはいくつかのヘッダーで始まり、イメージはII *で始まります。 TIFF画像でII *の前にヘッダー部分を削除する方法を教えてください。 以下はしかし、私は以下のTIFFから画像をsepereteする私の方法である TIFFファイルを開いてヘッダ部分を削除する方法

Exception in thread "main" java.lang.IllegalArgumentException: Bad endianness tag (not 0x4949 or 0x4d4d). 

* IIで開始していないため、TIFFに以下のような例外をヒットし、私は画像を区切るために使用しているコードです。

FileSeekableStream ss = new FileSeekableStream("D:\\Users\\Vinoth\\workspace\\Testing\\Testing.tif"); 
    ImageDecoder dec = ImageCodec.createImageDecoder("tiff", ss, null); 
    int count = dec.getNumPages(); 
    TIFFEncodeParam param = new TIFFEncodeParam(); 

    param.setLittleEndian(false); // Intel 
    System.out.println("This TIF has " + count + " image(s)"); 
    for (int i = 0; i < count; i++) { 
     RenderedImage page = dec.decodeAsRenderedImage(i); 
     File f = new File("D:\\Users\\Vinoth\\workspace\\Testing\\single_" + i + ".tif"); 
     System.out.println("Saving " + f.getCanonicalPath()); 
     ParameterBlock pb = new ParameterBlock(); 
     pb.addSource(page); 
     pb.add(f.toString()); 
     pb.add("tiff"); 
     pb.add(param); 
     RenderedOp r = JAI.create("filestore",pb); 
     r.dispose(); 
+0

3回の試行を経て、最終的にそれが得られます。http://stackoverflow.com/questions/38431971/in-java-exclude-a-string-while-encode-using-base64 http://stackoverflow.com/questions/38380277/split-tiff-files-to-multiple-files http://stackoverflow.com/questions/38418111/unable-to-encode-a-tiff-file-properly-some-characters-are-not-encoding – gpasch

答えて

0

私はDataInputStreamとDataOutputStreamを使用することができます。

バイト配列を使用して、forループ内に文字を格納して読み込みます。

関連する問題