Package: PreviewSettings
PreviewSettings
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PreviewSettings() |
|
|
|
|
|
||||||||||||||||||||
getLookupTable16bit() |
|
|
|
|
|
||||||||||||||||||||
getLookupTable8bit() |
|
|
|
|
|
||||||||||||||||||||
setLookupTable(short[], short[], short[], short[]) |
|
|
|
|
|
Coverage
1: /*
2: * *********************************************************************************************************************
3: *
4: * Mistral: open source imaging engine
5: * http://tidalwave.it/projects/mistral
6: *
7: * Copyright (C) 2003 - 2023 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/mistral-src
23: * git clone https://github.com/tidalwave-it/mistral-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.image.render;
28:
29: import java.awt.image.ByteLookupTable;
30: import java.awt.image.ShortLookupTable;
31:
32: /***********************************************************************************************************************
33: *
34: * This class holds preview settings for displaying an image.
35: *
36: * @author Fabrizio Giudici
37: *
38: **********************************************************************************************************************/
39: public class PreviewSettings
40: {
41: private byte[] redCurve8bit = new byte[256];
42: private byte[] greenCurve8bit = new byte[256];
43: private byte[] blueCurve8bit = new byte[256];
44: private byte[] alphaCurve8bit = new byte[256];
45: private ShortLookupTable lookupTable16bit;
46: private ByteLookupTable lookupTable8bit;
47:
48: /*******************************************************************************************************************
49: *
50: * TODO: it would be event better to pass abstract curves and leave to this
51: * class the responsibility of sampling them. Check out performances.
52: *
53: ******************************************************************************************************************/
54: public void setLookupTable (final short[] redCurve,
55: final short[] greenCurve,
56: final short[] blueCurve,
57: final short[] alphaCurve)
58: {
59: lookupTable16bit = new ShortLookupTable(0, new short[][]{redCurve, greenCurve, blueCurve, alphaCurve});
60:
61: // FIXME: use a better interpolation
62:• for (var i = 0; i < redCurve8bit.length; i++)
63: {
64: final var j = (i << 8) | (i & 0xff);
65: redCurve8bit[i] = (byte)(redCurve[j] >>> 8);
66: greenCurve8bit[i] = (byte)(greenCurve[j] >>> 8);
67: blueCurve8bit[i] = (byte)(blueCurve[j] >>> 8);
68: alphaCurve8bit[i] = (byte)(alphaCurve[j] >>> 8);
69: }
70:
71: lookupTable8bit = new ByteLookupTable(0,
72: new byte[][]{redCurve8bit,
73: greenCurve8bit,
74: blueCurve8bit,
75: alphaCurve8bit});
76: }
77:
78: /*******************************************************************************************************************
79: *
80: *
81: ******************************************************************************************************************/
82: public ShortLookupTable getLookupTable16bit()
83: {
84: return lookupTable16bit;
85: }
86:
87: /*******************************************************************************************************************
88: *
89: *
90: ******************************************************************************************************************/
91: public ByteLookupTable getLookupTable8bit()
92: {
93: return lookupTable8bit;
94: }
95: }