1 /* ImageOutputStream.java --
2 Copyright (C) 2004 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax
.imageio
.stream
;
41 import java
.io
.IOException
;
42 import java
.nio
.ByteOrder
;
45 * @author Michael Koch (konqueror@gmx.de)
47 public abstract class ImageOutputStreamImpl
extends ImageInputStreamImpl
48 implements ImageOutputStream
50 public ImageOutputStreamImpl()
55 protected void flushBits()
58 // FIXME: Implement me.
59 throw new Error("not implemented");
62 public void write(byte[] data
)
65 write(data
, 0, data
.length
);
68 public abstract void write(byte[] data
, int offset
, int len
)
71 public abstract void write(int value
)
74 public void writeBit(int bit
)
77 // FIXME: Implement me.
78 throw new Error("not implemented");
81 public void writeBits(long bits
, int numBits
)
84 // FIXME: Implement me.
85 throw new Error("not implemented");
88 public void writeBoolean(boolean value
)
91 writeByte(value ?
1 : 0);
94 public void writeByte(int value
)
100 public void writeBytes(String data
)
103 write(data
.getBytes());
106 public void writeChar(int value
)
109 writeShort((short) value
);
112 public void writeChars(char[] data
, int offset
, int len
)
115 for(int i
= 0; i
< len
; ++len
)
116 writeChar(data
[offset
+ i
]);
119 public void writeChars(String data
)
122 // FIXME: Implement me.
123 throw new Error("not implemented");
126 public void writeDouble(double value
)
129 writeLong((long) value
);
132 public void writeDoubles(double[] data
, int offset
, int len
)
135 for(int i
= 0; i
< len
; ++len
)
136 writeDouble(data
[offset
+ i
]);
139 public void writeFloat(float value
)
142 writeInt((int) value
);
145 public void writeFloats(float[] data
, int offset
, int len
)
148 for(int i
= 0; i
< len
; ++len
)
149 writeFloat(data
[offset
+ i
]);
152 public void writeInt(int value
)
155 if (getByteOrder() == ByteOrder
.LITTLE_ENDIAN
)
157 buffer
[0] = ((byte) value
);
158 buffer
[1] = ((byte) (value
>> 8));
159 buffer
[2] = ((byte) (value
>> 16));
160 buffer
[3] = ((byte) (value
>> 24));
164 buffer
[0] = ((byte) (value
>> 24));
165 buffer
[1] = ((byte) (value
>> 16));
166 buffer
[2] = ((byte) (value
>> 8));
167 buffer
[3] = ((byte) value
);
173 public void writeInts(int[] data
, int offset
, int len
)
176 for(int i
= 0; i
< len
; ++len
)
177 writeInt(data
[offset
+ i
]);
180 public void writeLong(long value
)
183 if (getByteOrder() == ByteOrder
.LITTLE_ENDIAN
)
185 buffer
[0] = ((byte) value
);
186 buffer
[1] = ((byte) (value
>> 8));
187 buffer
[2] = ((byte) (value
>> 16));
188 buffer
[3] = ((byte) (value
>> 24));
189 buffer
[4] = ((byte) (value
>> 32));
190 buffer
[5] = ((byte) (value
>> 40));
191 buffer
[6] = ((byte) (value
>> 48));
192 buffer
[7] = ((byte) (value
>> 56));
196 buffer
[0] = ((byte) (value
>> 56));
197 buffer
[1] = ((byte) (value
>> 48));
198 buffer
[2] = ((byte) (value
>> 40));
199 buffer
[3] = ((byte) (value
>> 32));
200 buffer
[4] = ((byte) (value
>> 24));
201 buffer
[5] = ((byte) (value
>> 16));
202 buffer
[6] = ((byte) (value
>> 8));
203 buffer
[7] = ((byte) value
);
209 public void writeLongs(long[] data
, int offset
, int len
)
212 for(int i
= 0; i
< len
; ++len
)
213 writeLong(data
[offset
+ i
]);
216 public void writeShort(int value
)
219 if (getByteOrder() == ByteOrder
.LITTLE_ENDIAN
)
221 buffer
[0] = ((byte) value
);
222 buffer
[1] = ((byte) (value
>> 8));
226 buffer
[0] = ((byte) (value
>> 8));
227 buffer
[1] = ((byte) value
);
233 public void writeShorts(short[] data
, int offset
, int len
)
236 for(int i
= 0; i
< len
; ++len
)
237 writeShort(data
[offset
+ i
]);
240 public void writeUTF(String data
)
243 throw new Error("not implemented");