- Timestamp:
- 07/25/06 14:44:49 (2 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/components/rendering/src/omeis/providers/re/data/Plane2D.java
r734 r821 33 33 34 34 //Third-party libraries 35 import java.nio.ByteBuffer; 35 36 import java.nio.ByteOrder; 36 37 import java.nio.MappedByteBuffer; … … 98 99 /** The Java type that we're using for pixel value retrieval */ 99 100 protected int javaType; 101 102 /** The sign of the type **/ 103 protected boolean signed; 100 104 101 105 … … 124 128 this.bytesPerPixel = PlaneFactory.bytesPerPixel(type); 125 129 this.javaType = PlaneFactory.javaType(type); 130 this.signed = PlaneFactory.isTypeSigned(type); 126 131 127 132 log.info("Created Plane2D with dimensions " + sizeX + "x" + sizeY + "x" … … 140 145 * @return The offset. 141 146 */ 142 protected abstract int calculateOffset(int x1, int x2);147 protected abstract int calculateOffset(int x1, int x2); 143 148 144 149 /** … … 157 162 int offset = calculateOffset(x1, x2); 158 163 159 switch(javaType)164 if (signed) 160 165 { 161 case PlaneFactory.BYTE: 162 return data.get(offset); 163 case PlaneFactory.SHORT: 164 return data.getShort(offset); 165 case PlaneFactory.INT: 166 return data.getInt(offset); 167 case PlaneFactory.FLOAT: 168 return data.getFloat(offset); 169 case PlaneFactory.DOUBLE: 170 return data.getDouble(offset); 171 } 166 switch(javaType) 167 { 168 case PlaneFactory.BYTE: 169 return data.get(offset); 170 case PlaneFactory.SHORT: 171 return data.getShort(offset); 172 case PlaneFactory.INT: 173 return data.getInt(offset); 174 case PlaneFactory.FLOAT: 175 return data.getFloat(offset); 176 case PlaneFactory.DOUBLE: 177 return data.getDouble(offset); 178 } 179 } else 180 { 181 switch(javaType) 182 { 183 case PlaneFactory.BYTE: 184 return (short) (data.get(offset) & 0xff); 185 case PlaneFactory.SHORT: 186 return (int) (data.getShort(offset) & 0xffff); 187 case PlaneFactory.INT: 188 return (long) (data.getInt(offset) & 0xffffffffL); 189 } 190 } 172 191 throw new RuntimeException("Unknown pixel type."); 173 192 } 174 175 193 }
