125 * @param hints the specified <code>RenderingHints</code>, or 126 * <code>null</code> 127 */ 128 public RescaleOp (float scaleFactor, float offset, RenderingHints hints) { 129 length = 1; 130 this.scaleFactors = new float[1]; 131 this.offsets = new float[1]; 132 this.scaleFactors[0] = scaleFactor; 133 this.offsets[0] = offset; 134 this.hints = hints; 135 } 136 137 /** 138 * Returns the scale factors in the given array. The array is also 139 * returned for convenience. If scaleFactors is null, a new array 140 * will be allocated. 141 * @param scaleFactors the array to contain the scale factors of 142 * this <code>RescaleOp</code> 143 * @return the scale factors of this <code>RescaleOp</code>. 144 */ 145 final public float[] getScaleFactors (float scaleFactors[]) { 146 if (scaleFactors == null) { 147 return this.scaleFactors.clone(); 148 } 149 System.arraycopy (this.scaleFactors, 0, scaleFactors, 0, 150 Math.min(this.scaleFactors.length, 151 scaleFactors.length)); 152 return scaleFactors; 153 } 154 155 /** 156 * Returns the offsets in the given array. The array is also returned 157 * for convenience. If offsets is null, a new array 158 * will be allocated. 159 * @param offsets the array to contain the offsets of 160 * this <code>RescaleOp</code> 161 * @return the offsets of this <code>RescaleOp</code>. 162 */ 163 final public float[] getOffsets(float offsets[]) { 164 if (offsets == null) { 165 return this.offsets.clone(); 166 } 167 168 System.arraycopy (this.offsets, 0, offsets, 0, 169 Math.min(this.offsets.length, offsets.length)); 170 return offsets; 171 } 172 173 /** 174 * Returns the number of scaling factors and offsets used in this 175 * RescaleOp. 176 * @return the number of scaling factors and offsets of this 177 * <code>RescaleOp</code>. 178 */ 179 final public int getNumFactors() { 180 return length; 181 } 182 183 184 /** 185 * Creates a ByteLookupTable to implement the rescale. 186 * The table may have either a SHORT or BYTE input. 187 * @param nElems Number of elements the table is to have. 188 * This will generally be 256 for byte and 189 * 65536 for short. 190 */ 191 private ByteLookupTable createByteLut(float scale[], 192 float off[], 193 int nBands, 194 int nElems) { 195 196 byte[][] lutData = new byte[scale.length][nElems]; 197 198 for (int band=0; band<scale.length; band++) { 199 float bandScale = scale[band]; | 125 * @param hints the specified <code>RenderingHints</code>, or 126 * <code>null</code> 127 */ 128 public RescaleOp (float scaleFactor, float offset, RenderingHints hints) { 129 length = 1; 130 this.scaleFactors = new float[1]; 131 this.offsets = new float[1]; 132 this.scaleFactors[0] = scaleFactor; 133 this.offsets[0] = offset; 134 this.hints = hints; 135 } 136 137 /** 138 * Returns the scale factors in the given array. The array is also 139 * returned for convenience. If scaleFactors is null, a new array 140 * will be allocated. 141 * @param scaleFactors the array to contain the scale factors of 142 * this <code>RescaleOp</code> 143 * @return the scale factors of this <code>RescaleOp</code>. 144 */ 145 public final float[] getScaleFactors (float scaleFactors[]) { 146 if (scaleFactors == null) { 147 return this.scaleFactors.clone(); 148 } 149 System.arraycopy (this.scaleFactors, 0, scaleFactors, 0, 150 Math.min(this.scaleFactors.length, 151 scaleFactors.length)); 152 return scaleFactors; 153 } 154 155 /** 156 * Returns the offsets in the given array. The array is also returned 157 * for convenience. If offsets is null, a new array 158 * will be allocated. 159 * @param offsets the array to contain the offsets of 160 * this <code>RescaleOp</code> 161 * @return the offsets of this <code>RescaleOp</code>. 162 */ 163 public final float[] getOffsets(float offsets[]) { 164 if (offsets == null) { 165 return this.offsets.clone(); 166 } 167 168 System.arraycopy (this.offsets, 0, offsets, 0, 169 Math.min(this.offsets.length, offsets.length)); 170 return offsets; 171 } 172 173 /** 174 * Returns the number of scaling factors and offsets used in this 175 * RescaleOp. 176 * @return the number of scaling factors and offsets of this 177 * <code>RescaleOp</code>. 178 */ 179 public final int getNumFactors() { 180 return length; 181 } 182 183 184 /** 185 * Creates a ByteLookupTable to implement the rescale. 186 * The table may have either a SHORT or BYTE input. 187 * @param nElems Number of elements the table is to have. 188 * This will generally be 256 for byte and 189 * 65536 for short. 190 */ 191 private ByteLookupTable createByteLut(float scale[], 192 float off[], 193 int nBands, 194 int nElems) { 195 196 byte[][] lutData = new byte[scale.length][nElems]; 197 198 for (int band=0; band<scale.length; band++) { 199 float bandScale = scale[band]; |