Mercurial > projects > dwt-mac
comparison dwt/internal/image/JPEGQuantizationTable.d @ 34:5123b17c98ef
Ported dwt.events.*, dwt.graphics.GC, Region, dwt.internal.image.*
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sun, 14 Sep 2008 01:45:57 +0200 |
parents | e831403a80a9 |
children |
comparison
equal
deleted
inserted
replaced
33:965ac0a77267 | 34:5123b17c98ef |
---|---|
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
8 * Contributors: | 8 * Contributors: |
9 * IBM Corporation - initial API and implementation | 9 * IBM Corporation - initial API and implementation |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
10 *******************************************************************************/ | 12 *******************************************************************************/ |
11 module dwt.internal.image; | 13 module dwt.internal.image.JPEGQuantizationTable; |
12 | 14 |
15 import dwt.internal.image.LEDataInputStream; | |
16 import dwt.internal.image.JPEGVariableSizeSegment; | |
17 import dwt.internal.image.JPEGFileFormat; | |
18 | |
19 import dwt.dwthelper.System; | |
13 | 20 |
14 final class JPEGQuantizationTable : JPEGVariableSizeSegment { | 21 final class JPEGQuantizationTable : JPEGVariableSizeSegment { |
15 public static byte[] DefaultLuminanceQTable = { | 22 public static byte[] DefaultLuminanceQTable = [ |
16 cast(byte)255, cast(byte)219, 0, 67, 0, | 23 cast(byte)255, cast(byte)219, 0, 67, 0, |
17 16, 11, 10, 16, 24, 40, 51, 61, | 24 16, 11, 10, 16, 24, 40, 51, 61, |
18 12, 12, 14, 19, 26, 58, 60, 55, | 25 12, 12, 14, 19, 26, 58, 60, 55, |
19 14, 13, 16, 24, 40, 57, 69, 56, | 26 14, 13, 16, 24, 40, 57, 69, 56, |
20 14, 17, 22, 29, 51, 87, 80, 62, | 27 14, 17, 22, 29, 51, 87, 80, 62, |
21 18, 22, 37, 56, 68, 109, 103, 77, | 28 18, 22, 37, 56, 68, 109, 103, 77, |
22 24, 35, 55, 64, 81, 104, 113, 92, | 29 24, 35, 55, 64, 81, 104, 113, 92, |
23 49, 64, 78, 87, 103, 121, 120, 101, | 30 49, 64, 78, 87, 103, 121, 120, 101, |
24 72, 92, 95, 98, 112, 100, 103, 99 | 31 72, 92, 95, 98, 112, 100, 103, 99 |
25 }; | 32 ]; |
26 public static byte[] DefaultChrominanceQTable = { | 33 public static byte[] DefaultChrominanceQTable = [ |
27 cast(byte)255, cast(byte)219, 0, 67, 1, | 34 cast(byte)255, cast(byte)219, 0, 67, 1, |
28 17, 18, 24, 47, 99, 99, 99, 99, | 35 17, 18, 24, 47, 99, 99, 99, 99, |
29 18, 21, 26, 66, 99, 99, 99, 99, | 36 18, 21, 26, 66, 99, 99, 99, 99, |
30 24, 26, 56, 99, 99, 99, 99, 99, | 37 24, 26, 56, 99, 99, 99, 99, 99, |
31 47, 66, 99, 99, 99, 99, 99, 99, | 38 47, 66, 99, 99, 99, 99, 99, 99, |
32 99, 99, 99, 99, 99, 99, 99, 99, | 39 99, 99, 99, 99, 99, 99, 99, 99, |
33 99, 99, 99, 99, 99, 99, 99, 99, | 40 99, 99, 99, 99, 99, 99, 99, 99, |
34 99, 99, 99, 99, 99, 99, 99, 99, | 41 99, 99, 99, 99, 99, 99, 99, 99, |
35 99, 99, 99, 99, 99, 99, 99, 99 | 42 99, 99, 99, 99, 99, 99, 99, 99 |
36 }; | 43 ]; |
37 | 44 |
38 public this(byte[] reference) { | 45 public this(byte[] reference) { |
39 super(reference); | 46 super(reference); |
40 } | 47 } |
41 | 48 |
42 public this(LEDataInputStream byteStream) { | 49 public this(LEDataInputStream byteStream) { |
82 System.arraycopy(keys, 0, newKeys, 0, keysIndex); | 89 System.arraycopy(keys, 0, newKeys, 0, keysIndex); |
83 return newKeys; | 90 return newKeys; |
84 } | 91 } |
85 | 92 |
86 public int[][] getQuantizationTablesValues() { | 93 public int[][] getQuantizationTablesValues() { |
87 int[][] values = new int[4][]; | 94 int[][] values = new int[][](4); |
88 int valuesIndex = 0; | 95 int valuesIndex = 0; |
89 int totalLength = getSegmentLength() - 2; | 96 int totalLength = getSegmentLength() - 2; |
90 int ofs = 4; | 97 int ofs = 4; |
91 while (totalLength > 64) { | 98 while (totalLength > 64) { |
92 int[] qk = new int[64]; | 99 int[] qk = new int[64]; |
104 } | 111 } |
105 ofs += 129; | 112 ofs += 129; |
106 totalLength -= 129; | 113 totalLength -= 129; |
107 } | 114 } |
108 if (valuesIndex >= values.length) { | 115 if (valuesIndex >= values.length) { |
109 int[][] newValues = new int[values.length + 4][]; | 116 int[][] newValues = new int[][](values.length + 4); |
110 System.arraycopy(values, 0, newValues, 0, values.length); | 117 System.arraycopy(values, 0, newValues, 0, values.length); |
111 values = newValues; | 118 values = newValues; |
112 } | 119 } |
113 values[valuesIndex] = qk; | 120 values[valuesIndex] = qk; |
114 valuesIndex++; | 121 valuesIndex++; |
115 } | 122 } |
116 int[][] newValues = new int[valuesIndex][]; | 123 int[][] newValues = new int[][](valuesIndex); |
117 System.arraycopy(values, 0, newValues, 0, valuesIndex); | 124 System.arraycopy(values, 0, newValues, 0, valuesIndex); |
118 return newValues; | 125 return newValues; |
119 } | 126 } |
120 | 127 |
121 public void scaleBy(int qualityFactor) { | 128 public void scaleBy(int qualityFactor) { |
157 totalLength -= 129; | 164 totalLength -= 129; |
158 } | 165 } |
159 } | 166 } |
160 } | 167 } |
161 | 168 |
162 public int signature() { | 169 public override int signature() { |
163 return JPEGFileFormat.DQT; | 170 return JPEGFileFormat.DQT; |
164 } | 171 } |
165 } | 172 } |