Changeset 3267


Ignore:
Timestamp:
10/11/07 13:45:37 (12 years ago)
Author:
melissa
Message:

Added new ColorSpace for 2-channel images; updated ImageTools accordingly.

Location:
trunk/loci/formats
Files:
1 added
1 edited

Legend:

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

    r3265 r3267  
    123123    if (c == 1) return makeImage(data, w, h); 
    124124    int dataType = DataBuffer.TYPE_BYTE; 
    125     if (c == 2) { 
    126       byte[] tmp = data; 
    127       data = new byte[(tmp.length / 2) * 3]; 
    128       if (interleaved) { 
    129         for (int i=0; i<tmp.length/2; i++) { 
    130           data[i*3] = tmp[i*2]; 
    131           data[i*3 + 1] = tmp[i*2 + 1]; 
    132         } 
    133       } 
    134       else System.arraycopy(tmp, 0, data, 0, tmp.length); 
    135       c++; 
    136     } 
    137125    DataBuffer buffer = new DataBufferByte(data, c * w * h); 
    138126    return constructImage(c, dataType, w, h, interleaved, false, buffer); 
     
    155143    if (c == 1) return makeImage(data, w, h); 
    156144    int dataType = DataBuffer.TYPE_USHORT; 
    157     if (c == 2) { 
    158       short[] tmp = data; 
    159       data = new short[(tmp.length / 2) * 3]; 
    160       if (interleaved) { 
    161         for (int i=0; i<tmp.length/2; i++) { 
    162           data[i*3] = tmp[i*2]; 
    163           data[i*3 + 1] = tmp[i*2 + 1]; 
    164         } 
    165       } 
    166       else System.arraycopy(tmp, 0, data, 0, tmp.length); 
    167       c++; 
    168     } 
    169145    DataBuffer buffer = new DataBufferUShort(data, c * w * h); 
    170146    return constructImage(c, dataType, w, h, interleaved, false, buffer); 
     
    187163    if (c == 1) return makeImage(data, w, h); 
    188164    int dataType = DataBuffer.TYPE_INT; 
    189     if (c == 2) { 
    190       int[] tmp = data; 
    191       data = new int[(tmp.length / 2) * 3]; 
    192       if (interleaved) { 
    193         for (int i=0; i<tmp.length/2; i++) { 
    194           data[i*3] = tmp[i*2]; 
    195           data[i*3 + 1] = tmp[i*2 + 1]; 
    196         } 
    197       } 
    198       else System.arraycopy(tmp, 0, data, 0, tmp.length); 
    199       c++; 
    200     } 
    201165    DataBuffer buffer = new DataBufferInt(data, c * w * h); 
    202166    return constructImage(c, dataType, w, h, interleaved, false, buffer); 
     
    219183    if (c == 1) return makeImage(data, w, h); 
    220184    int dataType = DataBuffer.TYPE_FLOAT; 
    221     if (c == 2) { 
    222       float[] tmp = data; 
    223       data = new float[(tmp.length / 2) * 3]; 
    224       if (interleaved) { 
    225         for (int i=0; i<tmp.length/2; i++) { 
    226           data[i*3] = tmp[i*2]; 
    227           data[i*3 + 1] = tmp[i*2 + 1]; 
    228         } 
    229       } 
    230       else System.arraycopy(tmp, 0, data, 0, tmp.length); 
    231       c++; 
    232     } 
    233185    DataBuffer buffer = new DataBufferFloat(data, c * w * h); 
    234186    return constructImage(c, dataType, w, h, interleaved, false, buffer); 
     
    251203    if (c == 1) return makeImage(data, w, h); 
    252204    int dataType = DataBuffer.TYPE_DOUBLE; 
    253     if (c == 2) { 
    254       double[] tmp = data; 
    255       data = new double[(tmp.length / 2) * 3]; 
    256       if (interleaved) { 
    257         for (int i=0; i<tmp.length/2; i++) { 
    258           data[i*3] = tmp[i*2]; 
    259           data[i*3 + 1] = tmp[i*2 + 1]; 
    260         } 
    261       } 
    262       else System.arraycopy(tmp, 0, data, 0, tmp.length); 
    263       c++; 
    264     } 
    265205    DataBuffer buffer = new DataBufferDouble(data, c * w * h); 
    266206    return constructImage(c, dataType, w, h, interleaved, false, buffer); 
     
    18851825        break; 
    18861826      case 2: 
    1887         type = ColorSpace.CS_sRGB; 
     1827        type = TwoChannelColorSpace.CS_2C; 
    18881828        break; 
    18891829      case 3: 
     
    18961836        return null; 
    18971837    } 
    1898     return new ComponentColorModel(ColorSpace.getInstance(type), c == 4, 
    1899       false, ColorModel.TRANSLUCENT, dataType); 
     1838    return new ComponentColorModel(TwoChannelColorSpace.getInstance(type), 
     1839      c == 4, false, ColorModel.TRANSLUCENT, dataType); 
    19001840  } 
    19011841 
Note: See TracChangeset for help on using the changeset viewer.