Changeset 3881


Ignore:
Timestamp:
04/04/08 08:24:08 (12 years ago)
Author:
melissa
Message:

Fixed TIFF pixel size calculations.

Location:
trunk/loci/formats
Files:
2 edited

Legend:

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

    r3015 r3881  
    7777 
    7878  /** Returns the value of the specified number as a double. */ 
    79   public double doubleValue() { return (double) longValue(); } 
     79  public double doubleValue() { 
     80    return denom == 0 ? Double.MAX_VALUE : ((double) numer / (double) denom); 
     81  } 
    8082 
    8183  /** Returns the value of the specified number as a float. */ 
    82   public float floatValue() { return (float) longValue(); } 
     84  public float floatValue() { return (float) doubleValue(); } 
    8385 
    8486  /** Returns the value of the specified number as an int. */ 
  • trunk/loci/formats/in/BaseTiffReader.java

    r3880 r3881  
    697697      TiffRational yResolution = TiffTools.getIFDRationalValue(ifds[0], 
    698698        TiffTools.Y_RESOLUTION, false); 
    699       float pixX = xResolution == null ? 0f : xResolution.floatValue(); 
    700       float pixY = yResolution == null ? 0f : yResolution.floatValue(); 
     699      float pixX = xResolution == null ? 0f : 1 / xResolution.floatValue(); 
     700      float pixY = yResolution == null ? 0f : 1 / yResolution.floatValue(); 
    701701 
    702702      switch (resolutionUnit) { 
    703703        case 2: 
    704704          // resolution is expressed in pixels per inch 
    705           pixX *= 0.0254; 
    706           pixY *= 0.0254; 
     705          pixX /= 0.0254; 
     706          pixY /= 0.0254; 
    707707          break; 
    708708        case 3: 
    709709          // resolution is expressed in pixels per centimeter 
    710           pixX /= 100; 
    711           pixY /= 100; 
     710          pixX *= 100; 
     711          pixY *= 100; 
    712712          break; 
    713713      } 
     
    715715      store.setDimensionsPhysicalSizeX(new Float(pixX), 0, 0); 
    716716      store.setDimensionsPhysicalSizeY(new Float(pixY), 0, 0); 
     717      store.setDimensionsPhysicalSizeZ(new Float(0), 0, 0); 
    717718 
    718719      // populate StageLabel 
Note: See TracChangeset for help on using the changeset viewer.