Changeset 1842


Ignore:
Timestamp:
11/22/06 08:20:40 (13 years ago)
Author:
melissa
Message:

Fixed bug in ImageIOReader that prevented data/tiff/ms-paint.png from being read
properly.

Location:
trunk/loci/formats
Files:
2 edited

Legend:

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

    r1839 r1842  
    902902  public static byte[] getBytes(BufferedImage img, boolean separated, int c) { 
    903903    byte[][] p = getBytes(img); 
    904     if (separated) return p[0]; 
     904    if (separated || p.length == 1) return p[0]; 
    905905    else { 
    906906      byte[] rtn = new byte[p.length * p[0].length]; 
  • trunk/loci/formats/in/ImageIOReader.java

    r1806 r1842  
    4141public abstract class ImageIOReader extends FormatReader { 
    4242 
     43  // -- Fields -- 
     44 
     45  /** Flag indicating image is RGB. */ 
     46  private boolean rgb; 
     47 
    4348  // -- Constructors -- 
    4449 
     
    6368  /** Checks if the images in the file are RGB. */ 
    6469  public boolean isRGB(String id) throws FormatException, IOException { 
    65     return true; 
     70    return rgb; 
    6671  } 
    6772 
     
    8085    throws FormatException, IOException 
    8186  { 
    82     return ImageTools.getBytes(openImage(id, no), false, no); 
     87    byte[] b = ImageTools.getBytes(openImage(id, no), false, no); 
     88    int bytesPerChannel = getSizeX(id) * getSizeY(id); 
     89    if (b.length > bytesPerChannel) { 
     90      byte[] tmp = b; 
     91      b = new byte[bytesPerChannel * 3]; 
     92      for (int i=0; i<3; i++) { 
     93        System.arraycopy(tmp, i * bytesPerChannel, b, i*bytesPerChannel,  
     94          bytesPerChannel); 
     95      } 
     96    } 
     97    return b; 
    8398  } 
    8499 
     
    104119    sizeX[0] = openImage(id, 0).getWidth(); 
    105120    sizeY[0] = openImage(id, 0).getHeight(); 
     121     
     122    rgb = openBytes(id, 0).length > getSizeX(id) * getSizeY(id); 
     123     
    106124    sizeZ[0] = 1; 
    107     sizeC[0] = 3; 
     125    sizeC[0] = rgb ? 3 : 1; 
    108126    sizeT[0] = 1; 
    109127    currentOrder[0] = "XYCZT"; 
Note: See TracChangeset for help on using the changeset viewer.