Changeset 3374


Ignore:
Timestamp:
11/16/07 09:37:29 (12 years ago)
Author:
melissa
Message:

16 bit data is now undifferenced properly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/TiffTools.java

    r3306 r3374  
    13481348      } 
    13491349 
    1350       undifference(data, bitsPerSample, imageWidth, planarConfig, predictor); 
     1350      undifference(data, bitsPerSample, imageWidth, planarConfig, predictor, 
     1351        littleEndian); 
    13511352      unpackBytes(samples, 0, data, bitsPerSample, photoInterp, colorMap, 
    13521353        littleEndian, maxValue, planarConfig, 0, 1, imageWidth); 
     
    13691370            bytes = uncompress(bytes, compression, size); 
    13701371            undifference(bytes, bitsPerSample, 
    1371               imageWidth, planarConfig, predictor); 
     1372              imageWidth, planarConfig, predictor, littleEndian); 
    13721373            int offset = (int) (imageWidth * row); 
    13731374            if (planarConfig == 2) { 
     
    13971398          byte[] bytes = new byte[samples[0].length]; 
    13981399          undifference(bytes, bitsPerSample, imageWidth, planarConfig, 
    1399             predictor); 
     1400            predictor, littleEndian); 
    14001401          int offset = (int) (imageWidth * row); 
    14011402          if (planarConfig == 2) offset = overallOffset / samplesPerPixel; 
     
    14121413      altBytes = uncompress(altBytes, compression, size); 
    14131414      undifference(altBytes, bitsPerSample, 
    1414         imageWidth, planarConfig, predictor); 
     1415        imageWidth, planarConfig, predictor, littleEndian); 
    14151416      unpackBytes(samples, (int) imageWidth, altBytes, bitsPerSample, 
    14161417        photoInterp, colorMap, littleEndian, maxValue, planarConfig, 0, 1, 
     
    19011902  /** Undoes in-place differencing according to the given predictor value. */ 
    19021903  public static void undifference(byte[] input, int[] bitsPerSample, 
    1903     long width, int planarConfig, int predictor) throws FormatException 
     1904    long width, int planarConfig, int predictor, boolean little) 
     1905    throws FormatException 
    19041906  { 
    19051907    if (predictor == 2) { 
     
    19071909      int len = bitsPerSample.length; 
    19081910      if (bitsPerSample[len - 1] == 0) len = 1; 
    1909       for (int b=0; b<input.length; b++) { 
    1910         if (b / len % width == 0) continue; 
    1911         input[b] += input[b - len]; 
     1911      if (bitsPerSample[0] <= 8) { 
     1912        for (int b=0; b<input.length; b++) { 
     1913          if (b / len % width == 0) continue; 
     1914          input[b] += input[b - len]; 
     1915        } 
     1916      } 
     1917      else if (bitsPerSample[0] <= 16) { 
     1918        short[] s = (short[]) DataTools.makeDataArray(input, 2, false, !little); 
     1919        for (int b=0; b<s.length; b++) { 
     1920          if (b / len % width == 0) continue; 
     1921          s[b] += s[b - len]; 
     1922        } 
     1923        for (int i=0; i<s.length; i++) { 
     1924          input[little ? i*2 : i*2 + 1] = (byte) (s[i] & 0xff); 
     1925          input[little ? i*2 + 1 : i*2] = (byte) ((s[i] >> 8) & 0xff); 
     1926        } 
    19121927      } 
    19131928    } 
Note: See TracChangeset for help on using the changeset viewer.