Changeset 6442
- Timestamp:
- 06/02/10 12:17:24 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/components/loci-plugins/src/loci/plugins/util/ImageProcessorReader.java
r6265 r6442 98 98 boolean first = true; 99 99 while (true) { 100 // TODO: This is the wrong place to prompt for the LuraWave code. 101 // This logic should be moved to a higher, GUI-specific level. 102 100 103 // read LuraWave license code, if available 101 104 String code = LuraWave.initLicenseCode(); 102 105 try { 103 b = openBytes(no, x, y, w, h); 106 b = openBytes(no, x, y, w, h); 104 107 break; 105 108 } … … 131 134 132 135 IndexColorModel cm = null; 133 if (isIndexed()) { 134 byte[][] byteTable = get8BitLookupTable(); 135 if (byteTable != null) { 136 cm = new IndexColorModel(8, byteTable[0].length, byteTable[0], 137 byteTable[1], byteTable[2]); 138 } 139 short[][] shortTable = get16BitLookupTable(); 140 if (shortTable != null) { 141 byteTable = new byte[3][256]; 142 143 for (int i=0; i<byteTable[0].length; i++) { 144 byteTable[0][i] = (byte) shortTable[0][i]; 145 byteTable[1][i] = (byte) shortTable[1][i]; 146 byteTable[2][i] = (byte) shortTable[2][i]; 147 } 148 149 cm = new IndexColorModel(8, byteTable[0].length, byteTable[0], 150 byteTable[1], byteTable[2]); 151 } 152 } 136 if (isIndexed()) cm = createIndexColorModel(); 153 137 154 138 // construct image processors … … 228 212 } 229 213 214 // -- Helper methods -- 215 216 private IndexColorModel createIndexColorModel() 217 throws FormatException, IOException 218 { 219 byte[][] byteTable = get8BitLookupTable(); 220 if (byteTable == null) byteTable = convertTo8Bit(get16BitLookupTable()); 221 if (byteTable == null) return null; 222 return new IndexColorModel(8, byteTable[0].length, 223 byteTable[0], byteTable[1], byteTable[2]); 224 } 225 226 private byte[][] convertTo8Bit(short[][] shortTable) { 227 if (shortTable == null) return null; 228 byte[][] byteTable = new byte[shortTable.length][256]; 229 for (int c=0; c<byteTable.length; c++) { 230 int len = Math.min(byteTable.length, shortTable[c].length); 231 for (int i=0; i<len; i++) byteTable[c][i] = (byte) shortTable[c][i]; 232 } 233 return byteTable; 234 } 235 230 236 }
Note: See TracChangeset
for help on using the changeset viewer.