1 |
pjm2 |
1.1 |
import java.io.*; |
2 |
|
|
import java.awt.*; |
3 |
|
|
import java.awt.image.*; |
4 |
|
|
import Acme.JPM.Encoders.*; |
5 |
|
|
|
6 |
pjm2 |
1.2 |
// Use the gif encoder bits to write our image to a gif file. |
7 |
pjm2 |
1.1 |
public class IscreamChartWriter { |
8 |
|
|
|
9 |
pjm2 |
1.2 |
// Dummy constructor. |
10 |
pjm2 |
1.1 |
public IscreamChartWriter() { |
11 |
|
|
|
12 |
|
|
} |
13 |
|
|
|
14 |
pjm2 |
1.2 |
// Write the gif file. |
15 |
pjm2 |
1.3 |
public static void writeChart(BufferedImage img, File filename) { |
16 |
pjm2 |
1.1 |
try { |
17 |
pjm2 |
1.3 |
FileOutputStream fos = new FileOutputStream(filename); |
18 |
pjm2 |
1.1 |
GifEncoder encoder = new GifEncoder(img, fos); |
19 |
|
|
|
20 |
|
|
encoder.encode(); |
21 |
|
|
|
22 |
|
|
fos.flush(); |
23 |
|
|
fos.close(); |
24 |
|
|
} |
25 |
|
|
catch(Exception e){ |
26 |
|
|
System.out.println("Could not write the .gif file: " + e); |
27 |
|
|
} |
28 |
|
|
|
29 |
|
|
System.out.println("Wrote " + filename + " successfully."); |
30 |
|
|
} |
31 |
|
|
} |