Mercurial > projects > dwt-mac
comparison dwt/internal/image/JPEGScanHeader.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.JPEGScanHeader; |
12 | |
13 | 14 |
14 import dwt.DWT; | 15 import dwt.DWT; |
16 import dwt.internal.image.JPEGVariableSizeSegment; | |
17 import dwt.internal.image.LEDataInputStream; | |
18 import dwt.internal.image.JPEGFileFormat; | |
19 import dwt.dwthelper.utils; | |
15 | 20 |
16 final class JPEGScanHeader : JPEGVariableSizeSegment { | 21 final class JPEGScanHeader : JPEGVariableSizeSegment { |
17 public int[][] componentParameters; | 22 public int[][] componentParameters; |
18 | 23 |
19 public this(byte[] reference) { | 24 public this(byte[] reference) { |
46 } | 51 } |
47 | 52 |
48 /* Used when decoding. */ | 53 /* Used when decoding. */ |
49 void initializeComponentParameters() { | 54 void initializeComponentParameters() { |
50 int compCount = getNumberOfImageComponents(); | 55 int compCount = getNumberOfImageComponents(); |
51 componentParameters = new int[0][]; | 56 componentParameters = null; |
52 for (int i = 0; i < compCount; i++) { | 57 for (int i = 0; i < compCount; i++) { |
53 int ofs = 5 + i * 2; | 58 int ofs = 5 + i * 2; |
54 int cid = reference[ofs] & 0xFF; | 59 int cid = reference[ofs] & 0xFF; |
55 int dc = (reference[ofs + 1] & 0xFF) >> 4; | 60 int dc = (reference[ofs + 1] & 0xFF) >> 4; |
56 int ac = reference[ofs + 1] & 0xF; | 61 int ac = reference[ofs + 1] & 0xF; |
57 if (componentParameters.length <= cid) { | 62 if (componentParameters.length <= cid) { |
58 int[][] newParams = new int[cid + 1][]; | 63 int[][] newParams = new int[][](cid + 1); |
59 System.arraycopy(componentParameters, 0, newParams, 0, componentParameters.length); | 64 System.arraycopy(componentParameters, 0, newParams, 0, componentParameters.length); |
60 componentParameters = newParams; | 65 componentParameters = newParams; |
61 } | 66 } |
62 componentParameters[cid] = new int[] { dc, ac }; | 67 componentParameters[cid] = [ dc, ac ]; |
63 } | 68 } |
64 } | 69 } |
65 | 70 |
66 /* Used when encoding. */ | 71 /* Used when encoding. */ |
67 public void initializeContents() { | 72 public void initializeContents() { |
88 | 93 |
89 public void setStartOfSpectralSelection(int anInteger) { | 94 public void setStartOfSpectralSelection(int anInteger) { |
90 reference[(2 * getNumberOfImageComponents()) + 5] = cast(byte)anInteger; | 95 reference[(2 * getNumberOfImageComponents()) + 5] = cast(byte)anInteger; |
91 } | 96 } |
92 | 97 |
93 public int signature() { | 98 public override int signature() { |
94 return JPEGFileFormat.SOS; | 99 return JPEGFileFormat.SOS; |
95 } | 100 } |
96 | 101 |
97 public bool verifyProgressiveScan() { | 102 public bool verifyProgressiveScan() { |
98 int start = getStartOfSpectralSelection(); | 103 int start = getStartOfSpectralSelection(); |