Changeset 4139


Ignore:
Timestamp:
06/27/08 12:26:58 (12 years ago)
Author:
melissa
Message:

Improved plane access time and memory consumption for ND2 files that use JPEG2000.

Location:
trunk/loci/formats
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/codec/JPEG2000Codec.java

    r4048 r4139  
    139139  { 
    140140    boolean littleEndian = false, interleaved = false; 
     141    long maxFP = 0; 
    141142    if (options instanceof Boolean) { 
    142143      littleEndian = ((Boolean) options).booleanValue(); 
     
    146147      littleEndian = ((Boolean) o[0]).booleanValue(); 
    147148      interleaved = ((Boolean) o[1]).booleanValue(); 
     149      if (o.length == 3) maxFP = ((Long) o[2]).longValue(); 
    148150    } 
    149151 
     
    151153    BufferedImage b = null; 
    152154    try { 
    153       byte[] buf = new byte[(int) (in.length() - in.getFilePointer())]; 
     155      if (maxFP == 0) maxFP = in.length(); 
     156      byte[] buf = new byte[(int) (maxFP - in.getFilePointer())]; 
    154157      in.read(buf); 
    155158 
     159      /* 
    156160      // HACK 
    157161      for (int i=0; i<buf.length-1; i++) { 
     
    165169        } 
    166170      } 
     171      */ 
    167172 
    168173      ByteArrayInputStream bis = new ByteArrayInputStream(buf); 
     
    178183      mciis.close(); 
    179184      buf = null; 
     185      b = null; 
    180186    } 
    181187    catch (ReflectException exc) { 
     
    201207      } 
    202208    } 
     209    single = null; 
     210 
    203211    return rtn; 
    204212  } 
  • trunk/loci/formats/in/ND2Reader.java

    r4132 r4139  
    127127    int pixel = bpp * getRGBChannelCount(); 
    128128 
     129    long maxFP = no == getImageCount() - 1 ? 
     130      in.length() : offsets[series][no + 1]; 
     131 
    129132    if (isJPEG) { 
    130133      in.seek(offsets[series][no]); 
    131       byte[] tmp = new JPEG2000Codec().decompress(in, new Boolean[] { 
     134      byte[] tmp = new JPEG2000Codec().decompress(in, new Object[] { 
    132135        new Boolean(core.littleEndian[series]), 
    133         new Boolean(core.interleaved[series])}); 
     136        new Boolean(core.interleaved[series]), new Long(maxFP)}); 
    134137      System.arraycopy(tmp, 0, buf, 0, (int) Math.min(tmp.length, buf.length)); 
     138      tmp = null; 
    135139    } 
    136140    else if (isLossless) { 
Note: See TracChangeset for help on using the changeset viewer.