Mercurial > hg > digilib-old
diff common/src/main/java/digilib/image/DocuImageImpl.java @ 1032:4e368c85cce4
CLOSED - # 22: wrong contrast setting. dito #23 (at least on OSX 10.7)
mostly juggling color channels.
also separate version number for DocuImage class.
author | robcast |
---|---|
date | Sat, 10 Mar 2012 23:09:38 +0100 |
parents | 28d007673346 |
children |
line wrap: on
line diff
--- a/common/src/main/java/digilib/image/DocuImageImpl.java Fri Mar 09 20:47:06 2012 +0100 +++ b/common/src/main/java/digilib/image/DocuImageImpl.java Sat Mar 10 23:09:38 2012 +0100 @@ -16,7 +16,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + */ package digilib.image; @@ -28,88 +28,112 @@ import java.util.LinkedList; import java.util.List; - import org.apache.log4j.Logger; import digilib.io.FileOpException; import digilib.io.ImageInput; import digilib.util.ImageSize; -/** Simple abstract implementation of the <code>DocuImage</code> interface. - * +/** + * Simple abstract implementation of the <code>DocuImage</code> interface. + * * This implementation provides basic functionality for the utility methods like - * <code>getKnownFileTypes</code>. Image methods like - * <code>loadImage</code>, <code>writeImage</code>, <code>getWidth</code>, - * <code>getHeight</code>, <code>crop</code> and <code>scale</code> must be - * implemented by derived classes. + * <code>getKnownFileTypes</code>. Image methods like <code>loadImage</code>, + * <code>writeImage</code>, <code>getWidth</code>, <code>getHeight</code>, + * <code>crop</code> and <code>scale</code> must be implemented by derived + * classes. */ public abstract class DocuImageImpl implements DocuImage { - /** logger */ - protected static final Logger logger = Logger.getLogger(DocuImage.class); - - /** Interpolation quality. */ - protected int quality = 0; - - /** epsilon for float comparisons. */ - public static final double epsilon = 1e-5; + /** DocuImage version */ + public static final String version = "DocuImageImpl 2.1"; + + /** logger */ + protected static final Logger logger = Logger.getLogger(DocuImage.class); - /** image size */ + /** Interpolation quality. */ + protected int quality = 0; + + /** epsilon for float comparisons. */ + public static final double epsilon = 1e-5; + + /** image size */ protected ImageSize imgSize = null; /** ImageInput that was read */ protected ImageInput input; - /** - * Returns the quality. - * @return int - */ - public int getQuality() { - return quality; - } + /** + * Returns the version. + * @return the version + */ + public String getVersion() { + return version; + } - /** - * Sets the quality. - * @param quality The quality to set - */ - public void setQuality(int quality) { - this.quality = quality; - } + /** + * Returns the quality. + * + * @return int + */ + public int getQuality() { + return quality; + } + + /** + * Sets the quality. + * + * @param quality + * The quality to set + */ + public void setQuality(int quality) { + this.quality = quality; + } - /** Crop and scale the current image. - * - * The current image is cropped to a rectangle of width, height at position - * x_off, y_off. The resulting image is scaled by the factor scale using the - * interpolation quality qual (0=worst). - * - * @param x_off X offset of the crop rectangle in pixel. - * @param y_off Y offset of the crop rectangle in pixel. - * @param width Width of the crop rectangle in pixel. - * @param height Height of the crop rectangle in pixel. - * @param scale Scaling factor. - * @param qual Interpolation quality (0=worst). - * @throws ImageOpException Exception thrown on any error. - */ - public void cropAndScale( - int x_off, int y_off, int width, int height, double scale, int qual) - throws ImageOpException { - // default implementation: first crop, then scale - setQuality(qual); - crop(x_off, y_off, width, height); - scale(scale, scale); - } - - /* (non-Javadoc) - * @see digilib.image.DocuImage#getMimetype() - */ - public String getMimetype() { - if (input != null) { - return input.getMimetype(); - } - return null; - } + /** + * Crop and scale the current image. + * + * The current image is cropped to a rectangle of width, height at position + * x_off, y_off. The resulting image is scaled by the factor scale using the + * interpolation quality qual (0=worst). + * + * @param x_off + * X offset of the crop rectangle in pixel. + * @param y_off + * Y offset of the crop rectangle in pixel. + * @param width + * Width of the crop rectangle in pixel. + * @param height + * Height of the crop rectangle in pixel. + * @param scale + * Scaling factor. + * @param qual + * Interpolation quality (0=worst). + * @throws ImageOpException + * Exception thrown on any error. + */ + public void cropAndScale(int x_off, int y_off, int width, int height, double scale, int qual) throws ImageOpException { + // default implementation: first crop, then scale + setQuality(qual); + crop(x_off, y_off, width, height); + scale(scale, scale); + } - /* (non-Javadoc) + /* + * (non-Javadoc) + * + * @see digilib.image.DocuImage#getMimetype() + */ + public String getMimetype() { + if (input != null) { + return input.getMimetype(); + } + return null; + } + + /* + * (non-Javadoc) + * * @see digilib.image.DocuImage#identify(digilib.io.ImageFile) */ public ImageInput identify(ImageInput ii) throws IOException { @@ -117,48 +141,45 @@ return null; } - public void rotate(double angle) throws ImageOpException { - // just a do-nothing implementation - } + public void rotate(double angle) throws ImageOpException { + // just a do-nothing implementation + } - public void mirror(double angle) throws ImageOpException { - // just a do-nothing implementation - } + public void mirror(double angle) throws ImageOpException { + // just a do-nothing implementation + } - public void enhance(float mult, float add) throws ImageOpException { - // just a do-nothing implementation - } + public void enhance(float mult, float add) throws ImageOpException { + // just a do-nothing implementation + } - public boolean isSubimageSupported() { - // partial loading not supported per default - return false; - } + public boolean isSubimageSupported() { + // partial loading not supported per default + return false; + } - public void loadSubimage(ImageInput ii, Rectangle region, int subsample) - throws FileOpException { - // empty implementation - } + public void loadSubimage(ImageInput ii, Rectangle region, int subsample) throws FileOpException { + // empty implementation + } - public void enhanceRGB(float[] rgbm, float[] rgba) - throws ImageOpException { - // emtpy implementation - } + public void enhanceRGB(float[] rgbm, float[] rgba) throws ImageOpException { + // emtpy implementation + } - public void colorOp(ColorOp op) throws ImageOpException { - // emtpy implementation - } - - public void dispose() { - // emtpy implementation - } + public void colorOp(ColorOp op) throws ImageOpException { + // emtpy implementation + } - public Iterator<String> getSupportedFormats() { - List<String> empty = new LinkedList<String>(); - return empty.iterator(); - } + public void dispose() { + // emtpy implementation + } - public void crop(int xoff, int yoff, int width, int height) - throws ImageOpException { + public Iterator<String> getSupportedFormats() { + List<String> empty = new LinkedList<String>(); + return empty.iterator(); + } + + public void crop(int xoff, int yoff, int width, int height) throws ImageOpException { // emtpy implementation } @@ -191,8 +212,6 @@ public abstract void scale(double scaleX, double scaleY) throws ImageOpException; - public abstract void writeImage(String mt, OutputStream ostream) - throws ImageOpException, FileOpException; + public abstract void writeImage(String mt, OutputStream ostream) throws ImageOpException, FileOpException; - }