Mercurial > hg > digilib-old
comparison servlet/src/digilib/image/DocuImageImpl.java @ 562:baaa5bab5e16 digilibPDF
trying to reduce use of ImageOps
author | robcast |
---|---|
date | Fri, 17 Dec 2010 16:24:03 +0100 |
parents | a5168978555f |
children | 4c51d71aef13 |
comparison
equal
deleted
inserted
replaced
561:a5168978555f | 562:baaa5bab5e16 |
---|---|
37 import digilib.io.ImageFile; | 37 import digilib.io.ImageFile; |
38 | 38 |
39 /** Simple abstract implementation of the <code>DocuImage</code> interface. | 39 /** Simple abstract implementation of the <code>DocuImage</code> interface. |
40 * | 40 * |
41 * This implementation provides basic functionality for the utility methods like | 41 * This implementation provides basic functionality for the utility methods like |
42 * <code>SetUtils</code>, and <code>getKnownFileTypes</code>. Image methods like | 42 * <code>getKnownFileTypes</code>. Image methods like |
43 * <code>loadImage</code>, <code>writeImage</code>, <code>getWidth</code>, | 43 * <code>loadImage</code>, <code>writeImage</code>, <code>getWidth</code>, |
44 * <code>getHeight</code>, <code>crop</code> and <code>scale</code> must be | 44 * <code>getHeight</code>, <code>crop</code> and <code>scale</code> must be |
45 * implemented by derived classes. | 45 * implemented by derived classes. |
46 */ | 46 */ |
47 public abstract class DocuImageImpl implements DocuImage { | 47 public abstract class DocuImageImpl implements DocuImage { |
73 public void setQuality(int quality) { | 73 public void setQuality(int quality) { |
74 this.quality = quality; | 74 this.quality = quality; |
75 } | 75 } |
76 | 76 |
77 /** Check image size and type and store in ImageFile f */ | 77 /** Check image size and type and store in ImageFile f */ |
78 public static boolean identifyImg(ImageFile imgf) throws IOException { | 78 public ImageFile identify(ImageFile imgf) throws IOException { |
79 } | |
80 | |
81 /** Check image size and type and store in ImageFile f */ | |
82 public boolean identify(ImageFile imgf) throws IOException { | |
83 // fileset to store the information | 79 // fileset to store the information |
84 File f = imgf.getFile(); | 80 File f = imgf.getFile(); |
85 if (f == null) { | 81 if (f == null) { |
86 throw new IOException("File not found!"); | 82 throw new IOException("File not found!"); |
87 } | 83 } |
98 imgf.setSize(d); | 94 imgf.setSize(d); |
99 imgf.setMimetype(iif.getMimeType()); | 95 imgf.setMimetype(iif.getMimeType()); |
100 //logger.debug(" format:"+iif.getFormatName()); | 96 //logger.debug(" format:"+iif.getFormatName()); |
101 raf.close(); | 97 raf.close(); |
102 logger.debug("image size: " + imgf.getSize()); | 98 logger.debug("image size: " + imgf.getSize()); |
103 return true; | 99 return imgf; |
104 } | 100 } |
105 return false; | 101 return null; |
106 } | 102 } |
107 | 103 |
108 /** Crop and scale the current image. | 104 /** Crop and scale the current image. |
109 * | 105 * |
110 * The current image is cropped to a rectangle of width, height at position | 106 * The current image is cropped to a rectangle of width, height at position |
120 * @throws ImageOpException Exception thrown on any error. | 116 * @throws ImageOpException Exception thrown on any error. |
121 */ | 117 */ |
122 public void cropAndScale( | 118 public void cropAndScale( |
123 int x_off, int y_off, int width, int height, double scale, int qual) | 119 int x_off, int y_off, int width, int height, double scale, int qual) |
124 throws ImageOpException { | 120 throws ImageOpException { |
125 | 121 // default implementation: first crop, then scale |
126 setQuality(qual); | 122 setQuality(qual); |
127 crop(x_off, y_off, width, height); | 123 crop(x_off, y_off, width, height); |
128 scale(scale, scale); | 124 scale(scale, scale); |
129 } | 125 } |
130 | 126 |
169 } | 165 } |
170 | 166 |
171 public void crop(int xoff, int yoff, int width, int height) | 167 public void crop(int xoff, int yoff, int width, int height) |
172 throws ImageOpException { | 168 throws ImageOpException { |
173 // TODO Auto-generated method stub | 169 // TODO Auto-generated method stub |
174 | |
175 } | 170 } |
176 | 171 |
177 public Image getAwtImage() { | 172 public Image getAwtImage() { |
178 // TODO Auto-generated method stub | 173 // TODO Auto-generated method stub |
179 return null; | 174 return null; |