1187 stream.writeShort(im.textGridTop);
1188 stream.writeShort(im.textGridWidth);
1189 stream.writeShort(im.textGridHeight);
1190 stream.write(im.characterCellWidth);
1191 stream.write(im.characterCellHeight);
1192 stream.write(im.textForegroundColor);
1193 stream.write(im.textBackgroundColor);
1194
1195 writeBlocks(im.text);
1196
1197 stream.write(0x00);
1198 } catch (IOException e) {
1199 throw new IIOException("I/O error writing Plain Text Extension!", e);
1200 }
1201 }
1202 }
1203
1204 private void writeApplicationExtension(GIFWritableImageMetadata im)
1205 throws IOException {
1206 if (im.applicationIDs != null) {
1207 Iterator iterIDs = im.applicationIDs.iterator();
1208 Iterator iterCodes = im.authenticationCodes.iterator();
1209 Iterator iterData = im.applicationData.iterator();
1210
1211 while (iterIDs.hasNext()) {
1212 try {
1213 stream.write(0x21);
1214 stream.write(0xff);
1215
1216 stream.write(11);
1217 stream.write((byte[])iterIDs.next(), 0, 8);
1218 stream.write((byte[])iterCodes.next(), 0, 3);
1219
1220 writeBlocks((byte[])iterData.next());
1221
1222 stream.write(0x00);
1223 } catch (IOException e) {
1224 throw new IIOException("I/O error writing Application Extension!", e);
1225 }
1226 }
1227 }
1228 }
1229
1230 private void writeCommentExtension(GIFWritableImageMetadata im)
1231 throws IOException {
1232 if (im.comments != null) {
1233 try {
1234 Iterator iter = im.comments.iterator();
1235 while (iter.hasNext()) {
1236 stream.write(0x21);
1237 stream.write(0xfe);
1238 writeBlocks((byte[])iter.next());
1239 stream.write(0x00);
1240 }
1241 } catch (IOException e) {
1242 throw new IIOException("I/O error writing Comment Extension!", e);
1243 }
1244 }
1245 }
1246
1247 private void writeImageDescriptor(int imageLeftPosition,
1248 int imageTopPosition,
1249 int imageWidth,
1250 int imageHeight,
1251 boolean interlaceFlag,
1252 boolean sortFlag,
1253 int bitsPerPixel,
1254 byte[] localColorTable)
1255 throws IOException {
1256
1257 try {
1258 stream.write(0x2c);
|
1187 stream.writeShort(im.textGridTop);
1188 stream.writeShort(im.textGridWidth);
1189 stream.writeShort(im.textGridHeight);
1190 stream.write(im.characterCellWidth);
1191 stream.write(im.characterCellHeight);
1192 stream.write(im.textForegroundColor);
1193 stream.write(im.textBackgroundColor);
1194
1195 writeBlocks(im.text);
1196
1197 stream.write(0x00);
1198 } catch (IOException e) {
1199 throw new IIOException("I/O error writing Plain Text Extension!", e);
1200 }
1201 }
1202 }
1203
1204 private void writeApplicationExtension(GIFWritableImageMetadata im)
1205 throws IOException {
1206 if (im.applicationIDs != null) {
1207 Iterator<byte[]> iterIDs = im.applicationIDs.iterator();
1208 Iterator<byte[]> iterCodes = im.authenticationCodes.iterator();
1209 Iterator<byte[]> iterData = im.applicationData.iterator();
1210
1211 while (iterIDs.hasNext()) {
1212 try {
1213 stream.write(0x21);
1214 stream.write(0xff);
1215
1216 stream.write(11);
1217 stream.write(iterIDs.next(), 0, 8);
1218 stream.write(iterCodes.next(), 0, 3);
1219
1220 writeBlocks(iterData.next());
1221
1222 stream.write(0x00);
1223 } catch (IOException e) {
1224 throw new IIOException("I/O error writing Application Extension!", e);
1225 }
1226 }
1227 }
1228 }
1229
1230 private void writeCommentExtension(GIFWritableImageMetadata im)
1231 throws IOException {
1232 if (im.comments != null) {
1233 try {
1234 Iterator<byte[]> iter = im.comments.iterator();
1235 while (iter.hasNext()) {
1236 stream.write(0x21);
1237 stream.write(0xfe);
1238 writeBlocks(iter.next());
1239 stream.write(0x00);
1240 }
1241 } catch (IOException e) {
1242 throw new IIOException("I/O error writing Comment Extension!", e);
1243 }
1244 }
1245 }
1246
1247 private void writeImageDescriptor(int imageLeftPosition,
1248 int imageTopPosition,
1249 int imageWidth,
1250 int imageHeight,
1251 boolean interlaceFlag,
1252 boolean sortFlag,
1253 int bitsPerPixel,
1254 byte[] localColorTable)
1255 throws IOException {
1256
1257 try {
1258 stream.write(0x2c);
|