85 super(offset,data.length); 86 numComponents = 1; 87 numEntries = data.length; 88 this.data = new short[1][]; 89 this.data[0] = data; 90 } 91 92 /** 93 * Returns the lookup table data by reference. If this ShortLookupTable 94 * was constructed using a single short array, the length of the returned 95 * array is one. 96 * @return ShortLookupTable data array. 97 */ 98 public final short[][] getTable(){ 99 return data; 100 } 101 102 /** 103 * Returns an array of samples of a pixel, translated with the lookup 104 * table. The source and destination array can be the same array. 105 * Array <code>dst</code> is returned. 106 * 107 * @param src the source array. 108 * @param dst the destination array. This array must be at least as 109 * long as <code>src</code>. If <code>dst</code> is 110 * <code>null</code>, a new array will be allocated having the 111 * same length as <code>src</code>. 112 * @return the array <code>dst</code>, an <code>int</code> array of 113 * samples. 114 * @exception ArrayIndexOutOfBoundsException if <code>src</code> is 115 * longer than <code>dst</code> or if for any element 116 * <code>i</code> of <code>src</code>, 117 * {@code (src[i]&0xffff)-offset} is either less than 118 * zero or greater than or equal to the length of the 119 * lookup table for any band. 120 */ 121 public int[] lookupPixel(int[] src, int[] dst){ 122 if (dst == null) { 123 // Need to alloc a new destination array 124 dst = new int[src.length]; 125 } 126 127 if (numComponents == 1) { 128 // Apply one LUT to all channels 129 for (int i=0; i < src.length; i++) { 130 int s = (src[i]&0xffff) - offset; 131 if (s < 0) { 132 throw new ArrayIndexOutOfBoundsException("src["+i+ 133 "]-offset is "+ 134 "less than zero"); 135 } 136 dst[i] = (int) data[0][s]; 137 } 138 } 139 else { 140 for (int i=0; i < src.length; i++) { 141 int s = (src[i]&0xffff) - offset; 142 if (s < 0) { 143 throw new ArrayIndexOutOfBoundsException("src["+i+ 144 "]-offset is "+ 145 "less than zero"); 146 } 147 dst[i] = (int) data[i][s]; 148 } 149 } 150 return dst; 151 } 152 153 /** 154 * Returns an array of samples of a pixel, translated with the lookup 155 * table. The source and destination array can be the same array. 156 * Array <code>dst</code> is returned. 157 * 158 * @param src the source array. 159 * @param dst the destination array. This array must be at least as 160 * long as <code>src</code>. If <code>dst</code> is 161 * <code>null</code>, a new array will be allocated having the 162 * same length as <code>src</code>. 163 * @return the array <code>dst</code>, an <code>int</code> array of 164 * samples. 165 * @exception ArrayIndexOutOfBoundsException if <code>src</code> is 166 * longer than <code>dst</code> or if for any element 167 * <code>i</code> of <code>src</code>, 168 * {@code (src[i]&0xffff)-offset} is either less than 169 * zero or greater than or equal to the length of the 170 * lookup table for any band. 171 */ 172 public short[] lookupPixel(short[] src, short[] dst){ 173 if (dst == null) { 174 // Need to alloc a new destination array 175 dst = new short[src.length]; 176 } 177 178 if (numComponents == 1) { 179 // Apply one LUT to all channels 180 for (int i=0; i < src.length; i++) { 181 int s = (src[i]&0xffff) - offset; 182 if (s < 0) { 183 throw new ArrayIndexOutOfBoundsException("src["+i+ 184 "]-offset is "+ 185 "less than zero"); 186 } 187 dst[i] = data[0][s]; | 85 super(offset,data.length); 86 numComponents = 1; 87 numEntries = data.length; 88 this.data = new short[1][]; 89 this.data[0] = data; 90 } 91 92 /** 93 * Returns the lookup table data by reference. If this ShortLookupTable 94 * was constructed using a single short array, the length of the returned 95 * array is one. 96 * @return ShortLookupTable data array. 97 */ 98 public final short[][] getTable(){ 99 return data; 100 } 101 102 /** 103 * Returns an array of samples of a pixel, translated with the lookup 104 * table. The source and destination array can be the same array. 105 * Array {@code dst} is returned. 106 * 107 * @param src the source array. 108 * @param dst the destination array. This array must be at least as 109 * long as {@code src}. If {@code dst} is 110 * {@code null}, a new array will be allocated having the 111 * same length as {@code src}. 112 * @return the array {@code dst}, an {@code int} array of 113 * samples. 114 * @exception ArrayIndexOutOfBoundsException if {@code src} is 115 * longer than {@code dst} or if for any element 116 * {@code i} of {@code src}, 117 * {@code (src[i]&0xffff)-offset} is either less than 118 * zero or greater than or equal to the length of the 119 * lookup table for any band. 120 */ 121 public int[] lookupPixel(int[] src, int[] dst){ 122 if (dst == null) { 123 // Need to alloc a new destination array 124 dst = new int[src.length]; 125 } 126 127 if (numComponents == 1) { 128 // Apply one LUT to all channels 129 for (int i=0; i < src.length; i++) { 130 int s = (src[i]&0xffff) - offset; 131 if (s < 0) { 132 throw new ArrayIndexOutOfBoundsException("src["+i+ 133 "]-offset is "+ 134 "less than zero"); 135 } 136 dst[i] = (int) data[0][s]; 137 } 138 } 139 else { 140 for (int i=0; i < src.length; i++) { 141 int s = (src[i]&0xffff) - offset; 142 if (s < 0) { 143 throw new ArrayIndexOutOfBoundsException("src["+i+ 144 "]-offset is "+ 145 "less than zero"); 146 } 147 dst[i] = (int) data[i][s]; 148 } 149 } 150 return dst; 151 } 152 153 /** 154 * Returns an array of samples of a pixel, translated with the lookup 155 * table. The source and destination array can be the same array. 156 * Array {@code dst} is returned. 157 * 158 * @param src the source array. 159 * @param dst the destination array. This array must be at least as 160 * long as {@code src}. If {@code dst} is 161 * {@code null}, a new array will be allocated having the 162 * same length as {@code src}. 163 * @return the array {@code dst}, an {@code int} array of 164 * samples. 165 * @exception ArrayIndexOutOfBoundsException if {@code src} is 166 * longer than {@code dst} or if for any element 167 * {@code i} of {@code src}, 168 * {@code (src[i]&0xffff)-offset} is either less than 169 * zero or greater than or equal to the length of the 170 * lookup table for any band. 171 */ 172 public short[] lookupPixel(short[] src, short[] dst){ 173 if (dst == null) { 174 // Need to alloc a new destination array 175 dst = new short[src.length]; 176 } 177 178 if (numComponents == 1) { 179 // Apply one LUT to all channels 180 for (int i=0; i < src.length; i++) { 181 int s = (src[i]&0xffff) - offset; 182 if (s < 0) { 183 throw new ArrayIndexOutOfBoundsException("src["+i+ 184 "]-offset is "+ 185 "less than zero"); 186 } 187 dst[i] = data[0][s]; |