Mercurial > hg > digilib-old
annotate common-imagej/src/main/java/digilib/image/ImageJ1DocuImage.java @ 1033:d5e181e3401c
pom only includes modules that are used by Profiles.
author | robcast |
---|---|
date | Sun, 11 Mar 2012 14:45:41 +0100 |
parents | b2d97b842612 |
children |
rev | line source |
---|---|
960
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
1 /** |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
2 * |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
3 */ |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
4 package digilib.image; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
5 |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
6 import ij.IJ; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
7 import ij.ImagePlus; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
8 import ij.plugin.JpegWriter; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
9 import ij.plugin.PNG_Writer; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
10 import ij.process.ImageProcessor; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
11 |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
12 import java.io.File; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
13 import java.io.FileInputStream; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
14 import java.io.IOException; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
15 import java.io.OutputStream; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
16 import java.util.Arrays; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
17 import java.util.Iterator; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
18 |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
19 import digilib.io.FileOpException; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
20 import digilib.io.FileOps; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
21 import digilib.io.ImageInput; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
22 import digilib.util.ImageSize; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
23 |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
24 /** Implementation of DocuImage using ImageJ version 1. |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
25 * |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
26 * @author casties |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
27 * |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
28 */ |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
29 public class ImageJ1DocuImage extends ImageInfoDocuImage { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
30 |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
31 protected ImagePlus img; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
32 protected ImageProcessor proc; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
33 |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
34 /* returns a list of supported image formats */ |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
35 public Iterator<String> getSupportedFormats() { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
36 String[] formats = new String[] {"JPG","PNG","TIFF"}; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
37 return Arrays.asList(formats).iterator(); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
38 } |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
39 |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
40 /* Check image size and type and store in ImageInput */ |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
41 public ImageInput identify(ImageInput input) throws IOException { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
42 // try parent method first |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
43 ImageInput ii = super.identify(input); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
44 if (ii != null) { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
45 return ii; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
46 } |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
47 logger.debug("identifying (ImageJ1) " + input); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
48 String path = input.getFile().getAbsolutePath(); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
49 img = IJ.openImage(path); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
50 // set size |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
51 ImageSize d = new ImageSize(img.getWidth(), img.getHeight()); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
52 input.setSize(d); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
53 // set mime type |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
54 if (input.getMimetype() == null) { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
55 String t = FileOps.mimeForFile(input.getFile()); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
56 input.setMimetype(t); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
57 } |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
58 return input; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
59 } |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
60 |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
61 /* (non-Javadoc) |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
62 * @see digilib.image.DocuImageImpl#loadImage(digilib.io.ImageInput) |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
63 */ |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
64 @Override |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
65 public void loadImage(ImageInput ii) throws FileOpException { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
66 this.input = ii; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
67 String path = ii.getFile().getAbsolutePath(); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
68 img = IJ.openImage(path); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
69 proc = img.getProcessor(); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
70 } |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
71 |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
72 /* (non-Javadoc) |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
73 * @see digilib.image.DocuImageImpl#crop(int, int, int, int) |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
74 */ |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
75 @Override |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
76 public void crop(int xoff, int yoff, int width, int height) |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
77 throws ImageOpException { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
78 proc.setRoi(xoff, yoff, width, height); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
79 ImageProcessor croppedProc = proc.crop(); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
80 proc = croppedProc; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
81 } |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
82 |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
83 /* (non-Javadoc) |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
84 * @see digilib.image.DocuImageImpl#scale(double, double) |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
85 */ |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
86 @Override |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
87 public void scale(double scaleX, double scaleY) throws ImageOpException { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
88 int newWidth = (int) Math.round(proc.getWidth() * scaleX); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
89 int newHeight = (int) Math.round(proc.getHeight() * scaleY); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
90 ImageProcessor scaledProc = proc.resize(newWidth, newHeight, false); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
91 proc = scaledProc; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
92 } |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
93 |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
94 /* (non-Javadoc) |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
95 * @see digilib.image.DocuImageImpl#writeImage(java.lang.String, java.io.OutputStream) |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
96 */ |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
97 @Override |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
98 public void writeImage(String mt, OutputStream ostream) |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
99 throws ImageOpException, FileOpException { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
100 File outFile; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
101 String filext = ".jpg"; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
102 if (mt.equals("image/png")) { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
103 filext = ".png"; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
104 } |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
105 try { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
106 outFile = File.createTempFile("imgj_temp", filext); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
107 } catch (IOException e) { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
108 throw new FileOpException(e.toString()); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
109 } |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
110 // save image to file |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
111 logger.debug("writeImage: mt="+mt); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
112 if (mt.equals("image/png")) { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
113 PNG_Writer writer = new PNG_Writer(); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
114 try { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
115 img = new ImagePlus("Image", proc); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
116 writer.writeImage(img, outFile.getAbsolutePath(), 0); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
117 } catch (Exception e) { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
118 // TODO Auto-generated catch block |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
119 e.printStackTrace(); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
120 } |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
121 } else { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
122 img = new ImagePlus("Image", proc); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
123 JpegWriter.save(img, outFile.getAbsolutePath(), 70); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
124 } |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
125 // now send file |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
126 FileInputStream inFile = null; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
127 try { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
128 inFile = new FileInputStream(outFile); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
129 byte dataBuffer[] = new byte[4096]; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
130 int len; |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
131 while ((len = inFile.read(dataBuffer)) != -1) { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
132 // copy out file |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
133 ostream.write(dataBuffer, 0, len); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
134 } |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
135 } catch (IOException e) { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
136 throw new FileOpException(e.toString()); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
137 } finally { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
138 try { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
139 if (inFile != null) { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
140 inFile.close(); |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
141 } |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
142 } catch (IOException e) { |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
143 // nothing to do |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
144 } |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
145 } |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
146 } |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
147 |
b2d97b842612
moved DocuImage implementations with non-standard toolkits (JAI, ImgeJ) into separate Maven modules.
robcast
parents:
diff
changeset
|
148 } |