01: /*******************************************************************************
02: * Copyright (c) 2000, 2003 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.swt.internal.image;
11:
12: class JPEGSegment {
13: public byte[] reference;
14:
15: JPEGSegment() {
16: }
17:
18: public JPEGSegment(byte[] reference) {
19: this .reference = reference;
20: }
21:
22: public int signature() {
23: return 0;
24: }
25:
26: public boolean verify() {
27: return getSegmentMarker() == signature();
28: }
29:
30: public int getSegmentMarker() {
31: return ((reference[0] & 0xFF) << 8 | (reference[1] & 0xFF));
32: }
33:
34: public void setSegmentMarker(int marker) {
35: reference[0] = (byte) ((marker & 0xFF00) >> 8);
36: reference[1] = (byte) (marker & 0xFF);
37: }
38:
39: public int getSegmentLength() {
40: return ((reference[2] & 0xFF) << 8 | (reference[3] & 0xFF));
41: }
42:
43: public void setSegmentLength(int length) {
44: reference[2] = (byte) ((length & 0xFF00) >> 8);
45: reference[3] = (byte) (length & 0xFF);
46: }
47:
48: public boolean writeToStream(LEDataOutputStream byteStream) {
49: try {
50: byteStream.write(reference);
51: return true;
52: } catch (Exception e) {
53: return false;
54: }
55: }
56: }
|