Changeset 4052


Ignore:
Timestamp:
05/16/08 09:38:58 (12 years ago)
Author:
melissa
Message:

Support for < 8 bit BMP images; minor LSM bug fix.

Location:
trunk/loci/formats/in
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/in/BMPReader.java

    r4048 r4052  
    2626import java.io.IOException; 
    2727import loci.formats.*; 
     28import loci.formats.codec.BitBuffer; 
    2829import loci.formats.meta.FilterMetadata; 
    2930import loci.formats.meta.MetadataStore; 
     
    108109    in.seek(global + rowsToSkip * rowLength); 
    109110 
     111    int planeSize = core.sizeX[0] * core.sizeY[0] * core.sizeC[0]; 
     112    if (bpp >= 8) planeSize *= (bpp / 8); 
     113    else planeSize /= (8 / bpp); 
     114    byte[] rawPlane = new byte[planeSize]; 
     115    in.read(rawPlane); 
     116 
     117    BitBuffer bb = new BitBuffer(rawPlane); 
     118 
    110119    if ((palette != null && palette[0].length > 0) || core.sizeC[0] == 1) { 
    111120      for (int row=h-1; row>=0; row--) { 
    112         in.skipBytes(x); 
    113         in.read(buf, row*w, w); 
    114         in.skipBytes(core.sizeX[0] - w - x); 
     121        bb.skipBits(x * bpp); 
     122        for (int i=0; i<w; i++) { 
     123          buf[row*w + i] = (byte) (bb.getBits(bpp) & 0xff); 
     124        } 
     125        bb.skipBits((core.sizeX[0] - w - x) * bpp); 
    115126      } 
    116127    } 
     
    118129      int len = core.sizeX[0] * core.sizeC[0]; 
    119130      for (int row=h-1; row>=y; row--) { 
    120         in.skipBytes(x * core.sizeC[0]); 
    121         in.read(buf, row*w*core.sizeC[0], w*core.sizeC[0]); 
    122         in.skipBytes(core.sizeC[0] * (core.sizeX[0] - w - x)); 
     131        bb.skipBits(x * core.sizeC[0] * bpp); 
     132        for (int i=0; i<w*core.sizeC[0]; i++) { 
     133          buf[row*w*core.sizeC[0] + i] = (byte) (bb.getBits(bpp) & 0xff); 
     134        } 
     135        bb.skipBits(core.sizeC[0] * (core.sizeX[0] - w - x) * bpp); 
    123136      } 
    124137      for (int i=0; i<buf.length/core.sizeC[0]; i++) { 
     
    170183 
    171184    core.sizeX[0] = in.readInt(); 
     185    //while ((core.sizeX[0] % 2) != 0) core.sizeX[0]++; 
    172186    core.sizeY[0] = in.readInt(); 
    173187 
     
    216230    // read the palette, if it exists 
    217231 
    218     if (nColors != 0) { 
    219       palette = new byte[3][nColors]; 
     232    if (nColors != 0 && bpp == 8) { 
     233      palette = new byte[3][256]; 
    220234 
    221235      for (int i=0; i<nColors; i++) { 
     
    233247    status("Populating metadata"); 
    234248 
    235     core.sizeC[0] = (palette == null && bpp == 8) ? 1 : 3; 
     249    core.sizeC[0] = bpp != 24 ? 1 : 3; 
    236250    if (bpp == 32) core.sizeC[0] = 4; 
    237251    if (bpp > 8) bpp /= core.sizeC[0]; 
    238     while (bpp % 8 != 0) bpp++; 
     252    //while (bpp % 8 != 0) bpp++; 
    239253 
    240254    switch (bpp) { 
    241       case 8: 
    242         core.pixelType[0] = FormatTools.UINT8; 
    243         break; 
    244255      case 16: 
    245256        core.pixelType[0] = FormatTools.UINT16; 
     
    248259        core.pixelType[0] = FormatTools.UINT32; 
    249260        break; 
    250     } 
    251  
    252     core.sizeX[0] = (int) ((in.length() - global) / 
    253       (core.sizeY[0] * (bpp / 8) * (palette != null ? 1 : core.sizeC[0]))); 
     261      default: 
     262        core.pixelType[0] = FormatTools.UINT8; 
     263    } 
    254264 
    255265    core.rgb[0] = core.sizeC[0] > 1; 
     
    286296    store.setDimensionsPhysicalSizeX(new Float(correctedX), 0, 0); 
    287297    store.setDimensionsPhysicalSizeY(new Float(correctedY), 0, 0); 
    288  
    289     // CTR CHECK 
    290 //    for (int i=0; i<core.sizeC[0]; i++) { 
    291 //      store.setLogicalChannel(i, null, null, null, null, null, null, null, null, 
    292 //       null, null, null, null, null, null, null, null, null, null, null, null, 
    293 //       null, null, null, null); 
    294 //    } 
    295298  } 
    296299 
  • trunk/loci/formats/in/ZeissLSMReader.java

    r4048 r4052  
    416416        else numEvents = (int) Math.min(numEvents, tmpEvents); 
    417417        in.order(!in.isLittleEndian()); 
     418 
     419        if (numEvents > 65535) numEvents = 0; 
    418420 
    419421        for (int i=0; i<numEvents; i++) { 
Note: See TracChangeset for help on using the changeset viewer.