(byte[] reds, byte[] greens, byte[] blues, int nColors)
| 279 | } |
| 280 | |
| 281 | void interpolate(byte[] reds, byte[] greens, byte[] blues, int nColors) { |
| 282 | byte[] r = new byte[nColors]; |
| 283 | byte[] g = new byte[nColors]; |
| 284 | byte[] b = new byte[nColors]; |
| 285 | System.arraycopy(reds, 0, r, 0, nColors); |
| 286 | System.arraycopy(greens, 0, g, 0, nColors); |
| 287 | System.arraycopy(blues, 0, b, 0, nColors); |
| 288 | double scale = nColors/256.0; |
| 289 | int i1, i2; |
| 290 | double fraction; |
| 291 | for (int i=0; i<256; i++) { |
| 292 | i1 = (int)(i*scale); |
| 293 | i2 = i1+1; |
| 294 | if (i2==nColors) i2 = nColors-1; |
| 295 | fraction = i*scale - i1; |
| 296 | reds[i] = (byte)((1.0-fraction)*(r[i1]&255) + fraction*(r[i2]&255)); |
| 297 | greens[i] = (byte)((1.0-fraction)*(g[i1]&255) + fraction*(g[i2]&255)); |
| 298 | blues[i] = (byte)((1.0-fraction)*(b[i1]&255) + fraction*(b[i2]&255)); |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | /** Opens a LUT and returns it as a LUT object. */ |
| 303 | public static LUT openLut(String pathOrURL) { |
no test coverage detected