97 off += n;
98 len -= n;
99 } catch (IOException e) {
100 break;
101 }
102 }
103 return len;
104 }
105
106 private static final int ExtractByte(byte buf[], int off) {
107 return (buf[off] & 0xFF);
108 }
109
110 private static final int ExtractWord(byte buf[], int off) {
111 return (buf[off] & 0xFF) | ((buf[off + 1] & 0xFF) << 8);
112 }
113
114 /**
115 * produce an image from the stream.
116 */
117 public void produceImage() throws IOException, ImageFormatException {
118 try {
119 readHeader();
120
121 int totalframes = 0;
122 int frameno = 0;
123 int nloops = -1;
124 int disposal_method = 0;
125 int delay = -1;
126 boolean loopsRead = false;
127 boolean isAnimation = false;
128
129 while (!aborted) {
130 int code;
131
132 switch (code = input.read()) {
133 case EXBLOCK:
134 switch (code = input.read()) {
135 case EX_GRAPHICS_CONTROL: {
136 byte buf[] = new byte[6];
221 return;
222 }
223 frameno++;
224 totalframes++;
225 break;
226
227 default:
228 case -1:
229 if (verbose) {
230 if (code == -1) {
231 System.err.println("Premature EOF in GIF file," +
232 " frame " + frameno);
233 } else {
234 System.err.println("corrupt GIF file (parse) ["
235 + code + "].");
236 }
237 }
238 if (frameno == 0) {
239 return;
240 }
241 // NOBREAK
242
243 case TERMINATOR:
244 if (nloops == 0 || nloops-- >= 0) {
245 try {
246 if (curframe != null) {
247 curframe.dispose();
248 curframe = null;
249 }
250 input.reset();
251 saved_image = null;
252 saved_model = null;
253 frameno = 0;
254 break;
255 } catch (IOException e) {
256 return; // Unable to reset input buffer
257 }
258 }
259 if (verbose && frameno != 1) {
260 System.out.println("processing GIF terminator,"
261 + " frames: " + frameno
|
97 off += n;
98 len -= n;
99 } catch (IOException e) {
100 break;
101 }
102 }
103 return len;
104 }
105
106 private static final int ExtractByte(byte buf[], int off) {
107 return (buf[off] & 0xFF);
108 }
109
110 private static final int ExtractWord(byte buf[], int off) {
111 return (buf[off] & 0xFF) | ((buf[off + 1] & 0xFF) << 8);
112 }
113
114 /**
115 * produce an image from the stream.
116 */
117 @SuppressWarnings("fallthrough")
118 public void produceImage() throws IOException, ImageFormatException {
119 try {
120 readHeader();
121
122 int totalframes = 0;
123 int frameno = 0;
124 int nloops = -1;
125 int disposal_method = 0;
126 int delay = -1;
127 boolean loopsRead = false;
128 boolean isAnimation = false;
129
130 while (!aborted) {
131 int code;
132
133 switch (code = input.read()) {
134 case EXBLOCK:
135 switch (code = input.read()) {
136 case EX_GRAPHICS_CONTROL: {
137 byte buf[] = new byte[6];
222 return;
223 }
224 frameno++;
225 totalframes++;
226 break;
227
228 default:
229 case -1:
230 if (verbose) {
231 if (code == -1) {
232 System.err.println("Premature EOF in GIF file," +
233 " frame " + frameno);
234 } else {
235 System.err.println("corrupt GIF file (parse) ["
236 + code + "].");
237 }
238 }
239 if (frameno == 0) {
240 return;
241 }
242 // Fall through
243
244 case TERMINATOR:
245 if (nloops == 0 || nloops-- >= 0) {
246 try {
247 if (curframe != null) {
248 curframe.dispose();
249 curframe = null;
250 }
251 input.reset();
252 saved_image = null;
253 saved_model = null;
254 frameno = 0;
255 break;
256 } catch (IOException e) {
257 return; // Unable to reset input buffer
258 }
259 }
260 if (verbose && frameno != 1) {
261 System.out.println("processing GIF terminator,"
262 + " frames: " + frameno
|