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 org.eclipse.swt.internal.image.LEDataOutputStream;
|
|
16
|
|
17
|
|
18 class JPEGSegment {
|
|
19 public byte[] reference;
|
|
20
|
|
21 this() {
|
|
22 }
|
|
23
|
|
24 public this(byte[] reference) {
|
|
25 this.reference = reference;
|
|
26 }
|
|
27
|
|
28 public int signature() {
|
|
29 return 0;
|
|
30 }
|
|
31
|
|
32 public bool verify() {
|
|
33 return getSegmentMarker() is signature();
|
|
34 }
|
|
35
|
|
36 public int getSegmentMarker() {
|
|
37 return ((reference[0] & 0xFF) << 8 | (reference[1] & 0xFF));
|
|
38 }
|
|
39
|
|
40 public void setSegmentMarker(int marker) {
|
|
41 reference[0] = cast(byte)((marker & 0xFF00) >> 8);
|
|
42 reference[1] = cast(byte)(marker & 0xFF);
|
|
43 }
|
|
44
|
|
45 public int getSegmentLength() {
|
|
46 return ((reference[2] & 0xFF) << 8 | (reference[3] & 0xFF));
|
|
47 }
|
|
48
|
|
49 public void setSegmentLength(int length) {
|
|
50 reference[2] = cast(byte)((length & 0xFF00) >> 8);
|
|
51 reference[3] = cast(byte)(length & 0xFF);
|
|
52 }
|
|
53
|
|
54 public bool writeToStream(LEDataOutputStream byteStream) {
|
|
55 try {
|
|
56 byteStream.write(reference);
|
|
57 return true;
|
|
58 } catch (Exception e) {
|
|
59 return false;
|
|
60 }
|
|
61 }
|
|
62 }
|