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: import org.eclipse.swt.*;
13:
14: abstract class JPEGVariableSizeSegment extends JPEGSegment {
15:
16: public JPEGVariableSizeSegment(byte[] reference) {
17: super (reference);
18: }
19:
20: public JPEGVariableSizeSegment(LEDataInputStream byteStream) {
21: try {
22: byte[] header = new byte[4];
23: byteStream.read(header);
24: reference = header; // to use getSegmentLength()
25: byte[] contents = new byte[getSegmentLength() + 2];
26: contents[0] = header[0];
27: contents[1] = header[1];
28: contents[2] = header[2];
29: contents[3] = header[3];
30: byteStream.read(contents, 4, contents.length - 4);
31: reference = contents;
32: } catch (Exception e) {
33: SWT.error(SWT.ERROR_IO, e);
34: }
35: }
36: }
|