Mercurial > hg > digilib-old
changeset 838:dd13310dbe29 stream
another try at invert. (works on osx...)
author | robcast |
---|---|
date | Tue, 01 Mar 2011 18:53:35 +0100 |
parents | e718f3441d39 |
children | ea6c8f92c929 |
files | servlet/src/digilib/image/ImageLoaderDocuImage.java servlet/src/digilib/servlet/Scaler.java |
diffstat | 2 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/servlet/src/digilib/image/ImageLoaderDocuImage.java Tue Mar 01 17:46:29 2011 +0100 +++ b/servlet/src/digilib/image/ImageLoaderDocuImage.java Tue Mar 01 18:53:35 2011 +0100 @@ -29,6 +29,7 @@ import java.awt.image.BufferedImage; import java.awt.image.ByteLookupTable; import java.awt.image.ColorConvertOp; +import java.awt.image.ColorModel; import java.awt.image.ConvolveOp; import java.awt.image.Kernel; import java.awt.image.LookupOp; @@ -63,7 +64,7 @@ protected BufferedImage img; /** interpolation type */ - protected RenderingHints renderHint; + protected RenderingHints renderHint = null; /** convolution kernels for blur() */ protected static Kernel[] convolutionKernels = { @@ -75,6 +76,7 @@ /** lookup table for inverting images (byte) */ protected static LookupTable invertByteTable; + protected static LookupTable invertRGBByteTable; static { byte[] invertByte = new byte[256]; @@ -84,10 +86,10 @@ orderedByte[i] = (byte) i; } // works for JPEG in q2 - invertByteTable = new ByteLookupTable(0, new byte[][] { - invertByte, invertByte, orderedByte, invertByte}); - // should work... - /* invertByteTable = new ByteLookupTable(0, invertByte); */ + invertRGBByteTable = new ByteLookupTable(0, new byte[][] { + orderedByte, invertByte, invertByte}); + // should work for all color models + invertByteTable = new ByteLookupTable(0, invertByte); } /** the size of the current image */ @@ -505,13 +507,15 @@ // convert image to grayscale logger.debug("Color op: grayscaling"); ColorConvertOp colop = new ColorConvertOp( - ColorSpace.getInstance(ColorSpace.CS_GRAY), null); + ColorSpace.getInstance(ColorSpace.CS_GRAY), renderHint); img = colop.filter(img, null); } else if (op == ColorOp.INVERT) { // invert colors i.e. invert every channel logger.debug("Color op: inverting"); // TODO: is this enough for all image types? LookupOp colop = new LookupOp(invertByteTable, renderHint); + ColorModel cm = img.getColorModel(); + logger.debug("colop: colormodel="+cm+" trans_bits="+cm.BITMASK); img = colop.filter(img, null); }
--- a/servlet/src/digilib/servlet/Scaler.java Tue Mar 01 17:46:29 2011 +0100 +++ b/servlet/src/digilib/servlet/Scaler.java Tue Mar 01 18:53:35 2011 +0100 @@ -31,7 +31,7 @@ private static final long serialVersionUID = 5289386646192471549L; /** digilib servlet version (for all components) */ - public static final String version = "1.9.1a15"; + public static final String version = "1.9.1a16"; /** servlet error codes */ public static enum Error {UNKNOWN, AUTH, FILE, IMAGE};