Changeset 3176


Ignore:
Timestamp:
09/18/07 14:35:13 (12 years ago)
Author:
melissa
Message:

Consolidated openImage implementations - haven't tested this on all readers yet, so let me know if something is broken.

Location:
trunk/loci/formats
Files:
38 edited

Legend:

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

    r3164 r3176  
    2626 
    2727import java.awt.image.BufferedImage; 
     28import java.awt.image.Raster; 
     29import java.awt.image.WritableRaster; 
    2830import java.io.IOException; 
    2931import java.util.*; 
     
    340342  } 
    341343 
     344  /* @see IFormatReader#openImage(int) */ 
     345  public BufferedImage openImage(int no) throws FormatException, IOException { 
     346    byte[] buf = openBytes(no); 
     347 
     348    if (getPixelType() == FormatTools.FLOAT) { 
     349      float[] f = new float[buf.length / 4]; 
     350      for (int i=0; i<f.length; i++) { 
     351        int p = DataTools.bytesToInt(buf, i*4, 4, isLittleEndian()); 
     352        f[i] = Float.intBitsToFloat(p); 
     353      } 
     354 
     355      if (normalizeData) f = DataTools.normalizeFloats(f); 
     356      return ImageTools.makeImage(f, core.sizeX[series], core.sizeY[series], 
     357        getRGBChannelCount(), true); 
     358    } 
     359 
     360 
     361    BufferedImage b = ImageTools.makeImage(buf, core.sizeX[series], 
     362      core.sizeY[series], isIndexed() ? 1 : getRGBChannelCount(), 
     363      core.interleaved[0], FormatTools.getBytesPerPixel(core.pixelType[series]), 
     364      core.littleEndian[series]); 
     365    if (isIndexed()) { 
     366      IndexedColorModel model = null; 
     367      if (core.pixelType[series] == FormatTools.UINT8 ||  
     368        core.pixelType[series] == FormatTools.INT8) 
     369      { 
     370        byte[][] table = get8BitLookupTable(); 
     371        model = new IndexedColorModel(8, table[0].length, table); 
     372      } 
     373      else if (core.pixelType[series] == FormatTools.UINT16 || 
     374        core.pixelType[series] == FormatTools.INT16) 
     375      { 
     376        short[][] table = get16BitLookupTable(); 
     377        model = new IndexedColorModel(16, table[0].length, table); 
     378      } 
     379      if (model != null) { 
     380        WritableRaster raster = Raster.createWritableRaster(b.getSampleModel(), 
     381          b.getData().getDataBuffer(), null); 
     382        b = new BufferedImage(model, raster, false, null); 
     383      } 
     384    } 
     385    return b; 
     386  } 
     387 
    342388  /* @see IFormatReader#openThumbImage(int) */ 
    343389  public BufferedImage openThumbImage(int no) 
  • trunk/loci/formats/in/AVIReader.java

    r3175 r3176  
    212212  } 
    213213 
    214   /* @see loci.formats.IFormatReader#openImage(int) */ 
    215   public BufferedImage openImage(int no) throws FormatException, IOException { 
    216     FormatTools.assertId(currentId, true, 1); 
    217     BufferedImage b = ImageTools.makeImage(openBytes(no), core.sizeX[0], 
    218       core.sizeY[0], isIndexed() ? 1 : core.sizeC[0], !core.interleaved[0], 
    219       FormatTools.getBytesPerPixel(core.pixelType[0]), core.littleEndian[0]); 
    220     if (isIndexed()) { 
    221       byte[][] table = get8BitLookupTable(); 
    222       IndexedColorModel model = 
    223         new IndexedColorModel(8, table[0].length, table); 
    224       WritableRaster raster = Raster.createWritableRaster(b.getSampleModel(), 
    225         b.getData().getDataBuffer(), null); 
    226       b = new BufferedImage(model, raster, false, null); 
    227     } 
    228     return b; 
    229   } 
    230  
    231214  // -- Internal FormatReader API methods -- 
    232215 
  • trunk/loci/formats/in/AliconaReader.java

    r3175 r3176  
    9797  } 
    9898 
    99   /* @see loci.formats.IFormatReader#openImage(int) */ 
    100   public BufferedImage openImage(int no) throws FormatException, IOException { 
    101     FormatTools.assertId(currentId, true, 1); 
    102     return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    103       1, false, numBytes, true); 
    104   } 
    105  
    10699  // -- Internal FormatReader API methods -- 
    107100 
  • trunk/loci/formats/in/BMPReader.java

    r3175 r3176  
    154154  } 
    155155 
    156   /* @see loci.formats.IFormatReader#openImage(int) */ 
    157   public BufferedImage openImage(int no) throws FormatException, IOException { 
    158     FormatTools.assertId(currentId, true, 1); 
    159     BufferedImage b = ImageTools.makeImage(openBytes(no), core.sizeX[0],  
    160       core.sizeY[0], core.sizeC[0], false); 
    161     if (isIndexed()) {  
    162       byte[][] table = get8BitLookupTable(); 
    163       IndexedColorModel model =  
    164         new IndexedColorModel(8, table[0].length, table); 
    165       WritableRaster raster = Raster.createWritableRaster(b.getSampleModel(), 
    166         b.getData().getDataBuffer(), null); 
    167       b = new BufferedImage(model, raster, false, null);  
    168     }  
    169     return b;  
    170   } 
    171  
    172156  // -- Internel FormatReader API methods -- 
    173157 
  • trunk/loci/formats/in/BaseTiffReader.java

    r3175 r3176  
    172172  } 
    173173 
    174   /* @see loci.formats.IFormatReader#openImage(int) */ 
    175   public BufferedImage openImage(int no) throws FormatException, IOException { 
    176     FormatTools.assertId(currentId, true, 1); 
    177     if (no < 0 || no >= getImageCount()) { 
    178       throw new FormatException("Invalid image number: " + no); 
    179     } 
    180  
    181     BufferedImage b = TiffTools.getImage(ifds[no], in); 
    182     if (isIndexed()) { 
    183       byte[][] table = get8BitLookupTable(); 
    184       IndexedColorModel model = null; 
    185       if (table != null) { 
    186         model = new IndexedColorModel(8, table[0].length, table); 
    187       } 
    188       else { 
    189         short[][] t = get16BitLookupTable(); 
    190         model = new IndexedColorModel(16, t[0].length, t); 
    191       } 
    192  
    193       WritableRaster raster = Raster.createWritableRaster(b.getSampleModel(), 
    194         b.getData().getDataBuffer(), null); 
    195       b = new BufferedImage(model, raster, false, null); 
    196     } 
    197     return b; 
    198   } 
    199  
    200174  // -- Internal BaseTiffReader API methods -- 
    201175 
  • trunk/loci/formats/in/BioRadReader.java

    r3175 r3176  
    121121    in.read(buf); 
    122122    return buf; 
    123   } 
    124  
    125   /* @see loci.formats.IFormatReader#openImage(int) */ 
    126   public BufferedImage openImage(int no) throws FormatException, IOException { 
    127     FormatTools.assertId(currentId, true, 1); 
    128     return ImageTools.makeImage(openBytes(no), core.sizeX[0], 
    129       core.sizeY[0], 1, false, byteFormat ? 1 : 2, LITTLE_ENDIAN); 
    130123  } 
    131124 
  • trunk/loci/formats/in/DeltavisionReader.java

    r3175 r3176  
    116116    in.read(buf); 
    117117    return buf; 
    118   } 
    119  
    120   /* @see loci.formats.IFormatReader#openImage(int) */ 
    121   public BufferedImage openImage(int no) 
    122     throws FormatException, IOException 
    123   { 
    124     FormatTools.assertId(currentId, true, 1); 
    125     return ImageTools.makeImage(openBytes(no), core.sizeX[0], 
    126       core.sizeY[0], 1, false, bytesPerPixel, core.littleEndian[0]); 
    127118  } 
    128119 
  • trunk/loci/formats/in/DicomReader.java

    r3175 r3176  
    154154    in.read(buf); 
    155155    return buf; 
    156   } 
    157  
    158   /* @see loci.formats.IFormatReader#openImage(int) */ 
    159   public BufferedImage openImage(int no) throws FormatException, IOException { 
    160     FormatTools.assertId(currentId, true, 1); 
    161     BufferedImage b = ImageTools.makeImage(openBytes(no), core.sizeX[0],  
    162       core.sizeY[0], indexed ? 1 : core.sizeC[0], core.interleaved[0],  
    163       bitsPerPixel / 8, core.littleEndian[0]); 
    164     if (indexed) { 
    165       byte[][] table = get8BitLookupTable(); 
    166       IndexedColorModel model = 
    167         new IndexedColorModel(8, table[0].length, table); 
    168       WritableRaster raster = Raster.createWritableRaster(b.getSampleModel(), 
    169         b.getData().getDataBuffer(), null); 
    170       b = new BufferedImage(model, raster, false, null); 
    171     } 
    172     return b; 
    173156  } 
    174157 
  • trunk/loci/formats/in/EPSReader.java

    r3175 r3176  
    147147    ras.close(); 
    148148    return buf; 
    149   } 
    150  
    151   /* @see loci.formats.IFormatReader#openImage(int) */ 
    152   public BufferedImage openImage(int no) throws FormatException, IOException { 
    153     FormatTools.assertId(currentId, true, 1); 
    154     return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    155       core.sizeC[0], core.interleaved[0], 
    156       FormatTools.getBytesPerPixel(core.pixelType[0]), core.littleEndian[0]); 
    157149  } 
    158150 
  • trunk/loci/formats/in/FitsReader.java

    r3175 r3176  
    8888  } 
    8989 
    90   /* @see loci.formats.IFormatReader#openImage(int) */ 
    91   public BufferedImage openImage(int no) throws FormatException, IOException { 
    92     return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    93       core.sizeC[0], core.interleaved[0], 
    94       FormatTools.getBytesPerPixel(core.pixelType[0]), core.littleEndian[0]); 
    95   } 
    96  
    9790  // -- Internal FormatReader API methods -- 
    9891 
  • trunk/loci/formats/in/FlexReader.java

    r3015 r3176  
    130130  } 
    131131 
    132   /* @see loci.formats.IFormatReader#openImage(int) */ 
    133   public BufferedImage openImage(int no) throws FormatException, IOException { 
    134     FormatTools.assertId(currentId, true, 1); 
    135     return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    136       getRGBChannelCount(), isInterleaved(), 
    137       FormatTools.getBytesPerPixel(core.pixelType[0]), isLittleEndian()); 
    138   } 
    139  
    140132  // -- Internal BaseTiffReader API methods -- 
    141133 
  • trunk/loci/formats/in/GIFReader.java

    r3175 r3176  
    166166 
    167167    return buf; 
    168   } 
    169  
    170   /* @see loci.formats.IFormatReader#openImage(int) */ 
    171   public BufferedImage openImage(int no) 
    172     throws FormatException, IOException 
    173   { 
    174     FormatTools.assertId(currentId, true, 1); 
    175     byte[] bytes = openBytes(no); 
    176     BufferedImage b = ImageTools.makeImage(bytes, core.sizeX[0], core.sizeY[0], 
    177       bytes.length / (core.sizeX[0] * core.sizeY[0]), false, 1, true); 
    178     byte[][] table = get8BitLookupTable(); 
    179     IndexedColorModel model = new IndexedColorModel(8, table[0].length, table); 
    180     WritableRaster raster = Raster.createWritableRaster(b.getSampleModel(), 
    181       b.getData().getDataBuffer(), null); 
    182     return new BufferedImage(model, raster, false, null);  
    183168  } 
    184169 
  • trunk/loci/formats/in/GatanReader.java

    r3175 r3176  
    9494    in.read(buf); 
    9595    return buf; 
    96   } 
    97  
    98   /* @see loci.formats.IFormatReader#openImage(int) */ 
    99   public BufferedImage openImage(int no) throws FormatException, IOException { 
    100     return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    101       1, false, bytesPerPixel, core.littleEndian[0]); 
    10296  } 
    10397 
  • trunk/loci/formats/in/ICSReader.java

    r3175 r3176  
    151151 
    152152    return buf; 
    153   } 
    154  
    155   /* @see loci.formats.IFormatReader#openImage(int) */ 
    156   public BufferedImage openImage(int no) throws FormatException, IOException { 
    157     FormatTools.assertId(currentId, true, 1); 
    158     byte[] plane = openBytes(no); 
    159     int channels = core.rgb[0] ? core.sizeC[0] : 1; 
    160  
    161     int bytes = bitsPerPixel / 8; 
    162  
    163     if (bytes == 4) { 
    164       float[] f = new float[core.sizeX[0] * core.sizeY[0] * channels]; 
    165       for (int i=0; i<f.length; i++) { 
    166         int p = DataTools.bytesToInt(plane, i*4, 4, core.littleEndian[0]); 
    167         f[i] = Float.intBitsToFloat(p); 
    168       } 
    169  
    170       if (normalizeData) f = DataTools.normalizeFloats(f); 
    171  
    172       return ImageTools.makeImage(f, core.sizeX[0], core.sizeY[0], 
    173         channels, true); 
    174     } 
    175  
    176     return ImageTools.makeImage(plane, core.sizeX[0], core.sizeY[0], channels, 
    177       true, bytes, core.littleEndian[0]); 
    178153  } 
    179154 
  • trunk/loci/formats/in/IPLabReader.java

    r3175 r3176  
    9595  } 
    9696 
    97   /* @see loci.formats.IFormatReader#openImage(int) */ 
    98   public BufferedImage openImage(int no) throws FormatException, IOException { 
    99     return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    100       core.rgb[0] ? core.sizeC[0] : 1, false, bps, core.littleEndian[0]); 
    101   } 
    102  
    10397  // -- Internal FormatReader API methods -- 
    10498 
  • trunk/loci/formats/in/IPWReader.java

    r3175 r3176  
    121121    stream.close(); 
    122122    return buf; 
    123   } 
    124  
    125   /* @see loci.formats.IFormatReader#openImage(int) */ 
    126   public BufferedImage openImage(int no) throws FormatException, IOException { 
    127     FormatTools.assertId(currentId, true, 1); 
    128     if (no < 0 || no >= getImageCount()) { 
    129       throw new FormatException("Invalid image number: " + no); 
    130     } 
    131  
    132     RandomAccessStream stream = getStream(no); 
    133     ifds = TiffTools.getIFDs(stream); 
    134     BufferedImage b = TiffTools.getImage(ifds[0], stream); 
    135     if (isIndexed()) { 
    136       IndexedColorModel model = null; 
    137       if (core.pixelType[0] == FormatTools.UINT8) { 
    138         byte[][] table = get8BitLookupTable(); 
    139         model = new IndexedColorModel(8, table[0].length, table); 
    140       } 
    141       else if (core.pixelType[0] == FormatTools.UINT16) { 
    142         short[][] table = get16BitLookupTable(); 
    143         model = new IndexedColorModel(16, table[0].length, table); 
    144       } 
    145       if (model != null) { 
    146         WritableRaster raster = Raster.createWritableRaster(b.getSampleModel(), 
    147           b.getData().getDataBuffer(), null); 
    148         b = new BufferedImage(model, raster, false, null); 
    149       } 
    150     } 
    151     return b; 
    152123  } 
    153124 
  • trunk/loci/formats/in/ImarisReader.java

    r3175 r3176  
    9595  } 
    9696 
    97   /* @see loci.formats.IFormatReader#openImage(int) */ 
    98   public BufferedImage openImage(int no) throws FormatException, IOException { 
    99     return ImageTools.makeImage(openBytes(no), core.sizeX[0], 
    100       core.sizeY[0], 1, false); 
    101   } 
    102  
    10397  // -- IFormatHandler API methods -- 
    10498 
  • trunk/loci/formats/in/KhorosReader.java

    r3175 r3176  
    104104    in.read(buf, 0, bufSize);  
    105105    return buf; 
    106   } 
    107  
    108   /* @see loci.formats.IFormatReader#openImage(int) */ 
    109   public BufferedImage openImage(int no) throws FormatException, IOException { 
    110     FormatTools.assertId(currentId, true, 1); 
    111  
    112     if (core.pixelType[0] == FormatTools.FLOAT) { 
    113       byte[] b = openBytes(no); 
    114       float[] f = new float[core.sizeX[0] * core.sizeY[0] * core.sizeC[0]]; 
    115       for (int i=0; i<f.length; i++) { 
    116         f[i] = Float.intBitsToFloat(DataTools.bytesToInt(b, 
    117           i*4, !core.littleEndian[0])); 
    118       } 
    119  
    120       return ImageTools.makeImage(f, core.sizeX[0], core.sizeY[0], 
    121         core.sizeC[0], core.interleaved[0]); 
    122     } 
    123  
    124     BufferedImage b = ImageTools.makeImage(openBytes(no), core.sizeX[0],  
    125       core.sizeY[0], isIndexed() ? 1 : core.sizeC[0], core.interleaved[0], 
    126       FormatTools.getBytesPerPixel(core.pixelType[0]), core.littleEndian[0]); 
    127     if (isIndexed()) { 
    128       byte[][] table = get8BitLookupTable(); 
    129       IndexedColorModel model =  
    130         new IndexedColorModel(8, table[0].length, table); 
    131       WritableRaster raster = Raster.createWritableRaster(b.getSampleModel(), 
    132         b.getData().getDataBuffer(), null); 
    133       b = new BufferedImage(model, raster, false, null);  
    134     } 
    135     return b; 
    136106  } 
    137107 
  • trunk/loci/formats/in/LIFReader.java

    r3175 r3176  
    120120    in.read(buf); 
    121121    return buf; 
    122   } 
    123  
    124   /* @see loci.formats.IFormatReader#openImage(int) */ 
    125   public BufferedImage openImage(int no) throws FormatException, IOException { 
    126     return ImageTools.makeImage(openBytes(no), core.sizeX[series], 
    127       core.sizeY[series], getRGBChannelCount(), false, bpp / 8, 
    128       core.littleEndian[series]); 
    129122  } 
    130123 
  • trunk/loci/formats/in/LeicaReader.java

    r3175 r3176  
    161161    tiff[series][no].close(); 
    162162    return buf; 
    163   } 
    164  
    165   /* @see loci.formats.IFormatReader#openImage(int) */ 
    166   public BufferedImage openImage(int no) throws FormatException, IOException { 
    167     FormatTools.assertId(currentId, true, 1); 
    168     if (no < 0 || no >= getImageCount()) { 
    169       throw new FormatException("Invalid image number: " + no); 
    170     } 
    171  
    172     tiff[series][no].setId((String) files[series].get(no)); 
    173     BufferedImage b = tiff[series][no].openImage(0); 
    174     tiff[series][no].close(); 
    175     return b; 
    176163  } 
    177164 
  • trunk/loci/formats/in/MRCReader.java

    r3175 r3176  
    8787  } 
    8888 
    89   /* @see loci.formats.IFormatReader#openImage(int) */ 
    90   public BufferedImage openImage(int no) throws FormatException, IOException { 
    91     if (isFloat) { 
    92       byte[] b = openBytes(no); 
    93       float[] f = new float[b.length / 4]; 
    94       for (int i=0; i<f.length; i++) { 
    95         f[i] = Float.intBitsToFloat(DataTools.bytesToInt(b, i*4, 
    96           4, core.littleEndian[0])); 
    97       } 
    98       return ImageTools.makeImage(f, core.sizeX[0], core.sizeY[0], 1, 
    99         core.interleaved[0]); 
    100     } 
    101         return ImageTools.makeImage(openBytes(no), core.sizeX[0], 
    102       core.sizeY[0], 1, true, bpp, core.littleEndian[0]); 
    103   } 
    104  
    10589  // -- Internal FormatReader API methods -- 
    10690 
  • trunk/loci/formats/in/MetamorphReader.java

    r3175 r3176  
    167167    r.setId(file); 
    168168    return r.openBytes(coords[0], buf); 
    169   } 
    170  
    171   /* @see loci.formats.IFormatReader#openImage(int) */ 
    172   public BufferedImage openImage(int no) throws FormatException, IOException { 
    173     FormatTools.assertId(currentId, true, 1); 
    174     if (stks == null || stks[series].length == 1) return super.openImage(no); 
    175  
    176     int[] coords = FormatTools.getZCTCoords(this, no % core.sizeZ[series]); 
    177     int ndx = no / core.sizeZ[series]; 
    178     String file = stks[series][ndx]; 
    179     
    180     if (r == null) r = new MetamorphReader(); 
    181     r.setId(file); 
    182     return r.openImage(coords[0]); 
    183169  } 
    184170 
  • trunk/loci/formats/in/MicromanagerReader.java

    r3175 r3176  
    9595    tiffReader.setId((String) tiffs.get(no)); 
    9696    return tiffReader.openBytes(0, buf); 
    97   } 
    98  
    99   /* @see loci.formats.IFormatReader#openImage(int) */ 
    100   public BufferedImage openImage(int no) throws FormatException, IOException { 
    101     FormatTools.assertId(currentId, true, 1); 
    102     if (no < 0 || no >= getImageCount()) { 
    103       throw new FormatException("Invalid image number: " + no); 
    104     } 
    105     tiffReader.setId((String) tiffs.get(no)); 
    106     return tiffReader.openImage(0); 
    10797  } 
    10898 
  • trunk/loci/formats/in/NRRDReader.java

    r3175 r3176  
    105105    } 
    106106    return helper.openBytes(no, buf); 
    107   } 
    108  
    109   /* @see loci.formats.IFormatReader#openImage(int) */ 
    110   public BufferedImage openImage(int no) throws FormatException, IOException { 
    111     FormatTools.assertId(currentId, true, 1); 
    112     if (core.pixelType[0] == FormatTools.FLOAT) { 
    113       byte[] b = openBytes(no); 
    114       float[] f = new float[core.sizeX[0] * core.sizeY[0] * core.sizeC[0]]; 
    115       for (int i=0; i<f.length; i++) { 
    116         f[i] = Float.intBitsToFloat( 
    117           DataTools.bytesToInt(b, i*4, 4, core.littleEndian[0])); 
    118       } 
    119       if (normalizeData) f = DataTools.normalizeFloats(f); 
    120       return ImageTools.makeImage(f, core.sizeX[0], core.sizeY[0], 
    121         core.sizeC[0], core.interleaved[0]); 
    122     } 
    123  
    124     return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    125       core.sizeC[0], core.interleaved[0], 
    126       FormatTools.getBytesPerPixel(core.pixelType[0]), core.littleEndian[0]); 
    127107  } 
    128108 
  • trunk/loci/formats/in/OIBReader.java

    r3175 r3176  
    120120    return (block[0] == 0xd0 && block[1] == 0xcf && 
    121121      block[2] == 0x11 && block[3] == 0xe0); 
    122   } 
    123  
    124   /* @see loci.formats.IFormatReader#openImage(int) */ 
    125   public BufferedImage openImage(int no) throws FormatException, IOException { 
    126     FormatTools.assertId(currentId, true, 1); 
    127     if (no < 0 || no >= getImageCount()) { 
    128       throw new FormatException("Invalid image number: " + no); 
    129     } 
    130  
    131     byte[] b = openBytes(no); 
    132     int bytes = b.length / (core.sizeX[series] * core.sizeY[series] * 
    133       getRGBChannelCount()); 
    134  
    135     return ImageTools.makeImage(b, core.sizeX[series], core.sizeY[series], 
    136       getRGBChannelCount(), false, bytes, core.littleEndian[series]); 
    137122  } 
    138123 
  • trunk/loci/formats/in/OIFReader.java

    r3175 r3176  
    104104    tiffReader[no].close(); 
    105105    return buf; 
    106   } 
    107  
    108   /* @see loci.formats.IFormatReader#openImage(int) */ 
    109   public BufferedImage openImage(int no) throws FormatException, IOException { 
    110     FormatTools.assertId(currentId, true, 1); 
    111     if (no < 0 || no >= getImageCount()) { 
    112       throw new FormatException("Invalid image number: " + no); 
    113     } 
    114  
    115     BufferedImage b = tiffReader[no].openImage(0); 
    116     ColorModel cm = ImageTools.makeColorModel(b.getRaster().getNumBands(), 
    117       b.getRaster().getTransferType(), null); 
    118     b = ImageTools.makeBuffered(b, cm); 
    119     tiffReader[no].close(); 
    120     return b; 
    121106  } 
    122107 
  • trunk/loci/formats/in/OMEXMLReader.java

    r3108 r3176  
    151151    } 
    152152    return pixels; 
    153   } 
    154  
    155   /* @see loci.formats.IFormatReader#openImage(int) */ 
    156   public BufferedImage openImage(int no) throws FormatException, IOException { 
    157     FormatTools.assertId(currentId, true, 1); 
    158     return ImageTools.makeImage(openBytes(no), core.sizeX[series], 
    159       core.sizeY[series], 1, false, bpp[series], core.littleEndian[series]); 
    160153  } 
    161154 
  • trunk/loci/formats/in/OpenlabRawReader.java

    r3175 r3176  
    102102  } 
    103103 
    104   /* @see loci.formats.IFormatReader#openImage(int) */ 
    105   public BufferedImage openImage(int no) throws FormatException, IOException { 
    106     return ImageTools.makeImage(openBytes(no), core.sizeX[0], 
    107       core.sizeY[0], core.sizeC[0], false, bytesPerPixel, false); 
    108   } 
    109  
    110104  // -- Internal FormatReader API methods -- 
    111105 
  • trunk/loci/formats/in/OpenlabReader.java

    r3175 r3176  
    300300    } 
    301301    return b; 
    302   } 
    303  
    304   /* @see loci.formats.IFormatReader#openImage(int) */ 
    305   public BufferedImage openImage(int no) throws FormatException, IOException { 
    306     FormatTools.assertId(currentId, true, 1); 
    307     if (no < 0 || no >= getImageCount()) { 
    308       throw new FormatException("Invalid image number: " + no); 
    309     } 
    310  
    311     byte[] b = openBytes(no); 
    312     bytesPerPixel = b.length / (core.sizeX[series] * core.sizeY[series]); 
    313     if (bytesPerPixel > 3) bytesPerPixel = 3; 
    314     return ImageTools.makeImage(b, core.sizeX[series], core.sizeY[series], 
    315       bytesPerPixel == 3 ? 3 : 1, false, 
    316       bytesPerPixel == 3 ? 1 : bytesPerPixel, false); 
    317302  } 
    318303 
  • trunk/loci/formats/in/PCIReader.java

    r3175 r3176  
    130130   
    131131    return buf; 
    132   } 
    133  
    134   /* @see loci.formats.IFormatReader#openImage(int) */ 
    135   public BufferedImage openImage(int no) throws FormatException, IOException { 
    136     FormatTools.assertId(currentId, true, 1); 
    137     return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    138       getRGBChannelCount(), !core.interleaved[0],  
    139       FormatTools.getBytesPerPixel(core.pixelType[0]), core.littleEndian[0]); 
    140132  } 
    141133 
  • trunk/loci/formats/in/PGMReader.java

    r3175 r3176  
    109109  } 
    110110 
    111   /* @see loci.formats.IFormatReader#openImage(int) */ 
    112   public BufferedImage openImage(int no) throws FormatException, IOException { 
    113     return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    114       core.sizeC[0], core.interleaved[0], 
    115       FormatTools.getBytesPerPixel(core.pixelType[0]), core.littleEndian[0]); 
    116   } 
    117  
    118111  // -- Internal FormatReader API methods -- 
    119112 
  • trunk/loci/formats/in/PerkinElmerReader.java

    r3175 r3176  
    9898    ras.close(); 
    9999    return b; 
    100   } 
    101  
    102   /* @see loci.formats.IFormatReader#openImage(int) */ 
    103   public BufferedImage openImage(int no) throws FormatException, IOException { 
    104     FormatTools.assertId(currentId, true, 1); 
    105     if (no < 0 || no >= getImageCount()) { 
    106       throw new FormatException("Invalid image number: " + no); 
    107     } 
    108     if (isTiff) { 
    109       int idx = no / core.sizeC[0]; 
    110       tiff[idx].setId(files[idx]); 
    111       return tiff[idx].openImage(0); 
    112     } 
    113  
    114     byte[] b = openBytes(no); 
    115     int bpp = b.length / (core.sizeX[0] * core.sizeY[0]); 
    116     return ImageTools.makeImage(b, core.sizeX[0], core.sizeY[0], 1, 
    117       false, bpp, core.littleEndian[0]); 
    118100  } 
    119101 
  • trunk/loci/formats/in/PrairieReader.java

    r3175 r3176  
    146146    tiff.openBytes(0, buf); 
    147147    return buf; 
    148   } 
    149  
    150   /* @see loci.formats.IFormatReader#openImage(int) */ 
    151   public BufferedImage openImage(int no) throws FormatException, IOException { 
    152     FormatTools.assertId(currentId, true, 1); 
    153     if (no < 0 || no >= getImageCount()) { 
    154       throw new FormatException("Invalid image number: " + no); 
    155     } 
    156     tiff.setId(files[no]); 
    157     return tiff.openImage(0); 
    158148  } 
    159149 
  • trunk/loci/formats/in/SDTReader.java

    r3175 r3176  
    172172  } 
    173173 
    174   /* @see loci.formats.IFormatReader#openImage(int) */ 
    175   public BufferedImage openImage(int no) throws FormatException, IOException { 
    176     FormatTools.assertId(currentId, true, 1); 
    177     return ImageTools.makeImage(openBytes(no), core.sizeX[series], 
    178       core.sizeY[series], getRGBChannelCount(), false, 2, true); 
    179   } 
    180  
    181174  // -- Internal FormatReader API methods -- 
    182175 
  • trunk/loci/formats/in/SlidebookReader.java

    r3175 r3176  
    8989    in.read(buf); 
    9090    return buf; 
    91   } 
    92  
    93   /* @see loci.formats.IFormatReader#openImage(int) */ 
    94   public BufferedImage openImage(int no) throws FormatException, IOException { 
    95     FormatTools.assertId(currentId, true, 1); 
    96     return ImageTools.makeImage(openBytes(no), core.sizeX[0], 
    97       core.sizeY[0], 1, true, 2, true); 
    9891  } 
    9992 
  • trunk/loci/formats/in/VisitechReader.java

    r3175 r3176  
    9696    s.close(); 
    9797    return buf; 
    98   } 
    99  
    100   /* @see loci.formats.IFormatReader#openImage(int) */ 
    101   public BufferedImage openImage(int no) throws FormatException, IOException { 
    102     return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    103       1, core.interleaved[0], FormatTools.getBytesPerPixel(core.pixelType[0]), 
    104       core.littleEndian[0]); 
    10598  } 
    10699 
  • trunk/loci/formats/in/ZeissLSMReader.java

    r3175 r3176  
    116116    TiffTools.getSamples(ifds[2*no], in, buf); 
    117117    return swapIfRequired(buf); 
    118   } 
    119  
    120   /* @see loci.formats.IFormatReader#openImage(int) */ 
    121   public BufferedImage openImage(int no) throws FormatException, IOException { 
    122     FormatTools.assertId(currentId, true, 1); 
    123     if (no < 0 || no >= getImageCount()) { 
    124       throw new FormatException("Invalid image number: " + no); 
    125     } 
    126  
    127     ifds = TiffTools.getIFDs(in); 
    128     return TiffTools.getImage(ifds[2*no], in); 
    129118  } 
    130119 
  • trunk/loci/formats/in/ZeissZVIReader.java

    r3175 r3176  
    230230      return openBytes(no, buf); 
    231231    } 
    232   } 
    233  
    234   /* @see loci.formats.IFormatReader#openImage(int) */ 
    235   public BufferedImage openImage(int no) throws FormatException, IOException { 
    236     FormatTools.assertId(currentId, true, 1); 
    237     return ImageTools.makeImage(openBytes(no), core.sizeX[0], core.sizeY[0], 
    238       getRGBChannelCount(), true, bpp == 3 ? 1 : bpp, true, 
    239       validBits); 
    240232  } 
    241233 
Note: See TracChangeset for help on using the changeset viewer.