25
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 * Port to the D programming language:
|
|
11 * Frank Benoit <benoit@tionex.de>
|
|
12 *******************************************************************************/
|
|
13 module org.eclipse.swt.internal.image.JPEGSegment;
|
|
14
|
|
15 import java.lang.all;
|
|
16
|
|
17 import org.eclipse.swt.internal.image.LEDataOutputStream;
|
|
18
|
|
19
|
|
20 class JPEGSegment {
|
|
21 public byte[] reference;
|
|
22
|
|
23 this() {
|
|
24 }
|
|
25
|
|
26 public this(byte[] reference) {
|
|
27 this.reference = reference;
|
|
28 }
|
|
29
|
|
30 public int signature() {
|
|
31 return 0;
|
|
32 }
|
|
33
|
|
34 public bool verify() {
|
|
35 return getSegmentMarker() is signature();
|
|
36 }
|
|
37
|
|
38 public int getSegmentMarker() {
|
|
39 return ((reference[0] & 0xFF) << 8 | (reference[1] & 0xFF));
|
|
40 }
|
|
41
|
|
42 public void setSegmentMarker(int marker) {
|
|
43 reference[0] = cast(byte)((marker & 0xFF00) >> 8);
|
|
44 reference[1] = cast(byte)(marker & 0xFF);
|
|
45 }
|
|
46
|
|
47 public int getSegmentLength() {
|
|
48 return ((reference[2] & 0xFF) << 8 | (reference[3] & 0xFF));
|
|
49 }
|
|
50
|
|
51 public void setSegmentLength(int length) {
|
|
52 reference[2] = cast(byte)((length & 0xFF00) >> 8);
|
|
53 reference[3] = cast(byte)(length & 0xFF);
|
|
54 }
|
|
55
|
|
56 public bool writeToStream(LEDataOutputStream byteStream) {
|
|
57 try {
|
|
58 byteStream.write(reference);
|
|
59 return true;
|
|
60 } catch (Exception e) {
|
|
61 return false;
|
|
62 }
|
|
63 }
|
|
64 }
|