Mercurial > hg > digilib-old
changeset 844:73dd59b48c5e stream
Merge from jquery branch
a7e157d258e86b9ba7470239f6b49d73ff200486
author | robcast |
---|---|
date | Fri, 04 Mar 2011 17:49:15 +0100 |
parents | ba449162d77f (diff) a7e157d258e8 (current diff) |
children | a29f53d8b7dd |
files | |
diffstat | 2 files changed, 26 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/servlet/src/digilib/image/ImageLoaderDocuImage.java Tue Mar 01 22:00:50 2011 +0100 +++ b/servlet/src/digilib/image/ImageLoaderDocuImage.java Fri Mar 04 17:49:15 2011 +0100 @@ -75,21 +75,31 @@ }; /** lookup table for inverting images (byte) */ - protected static LookupTable invertByteTable; - protected static LookupTable invertRGBByteTable; + protected static LookupTable invertSingleByteTable; + protected static LookupTable invertRgbaByteTable; static { byte[] invertByte = new byte[256]; byte[] orderedByte = new byte[256]; + byte[] nullByte = new byte[256]; for (int i = 0; i < 256; ++i) { invertByte[i] = (byte) (256 - i); orderedByte[i] = (byte) i; + nullByte[i] = 0; } - // works for JPEG in q2 - invertRGBByteTable = new ByteLookupTable(0, new byte[][] { - orderedByte, invertByte, invertByte}); - // should work for all color models - invertByteTable = new ByteLookupTable(0, invertByte); + // should(!) work for all color models + invertSingleByteTable = new ByteLookupTable(0, invertByte); + // but doesn't work with alpha channel on all platforms + String ver = System.getProperty("java.version"); + String os = System.getProperty("os.name"); + logger.debug("os="+os+" ver="+ver); + if (os.startsWith("Linux") && ver.startsWith("1.6")) { + // GRAB(WTF?) works in Linux JDK1.6 with transparency + invertRgbaByteTable = new ByteLookupTable(0, new byte[][] { + invertByte, invertByte, orderedByte, invertByte}); + } else { + invertRgbaByteTable = invertSingleByteTable; + } } /** the size of the current image */ @@ -513,8 +523,15 @@ // 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); + LookupTable invtbl = null; ColorModel cm = img.getColorModel(); + if (cm.hasAlpha()) { + // JDK 1.6 in Linux (at least) is broken :-( + invtbl = invertRgbaByteTable; + } else { + invtbl = invertSingleByteTable; + } + LookupOp colop = new LookupOp(invtbl, renderHint); logger.debug("colop: image="+img+" colormodel="+cm); img = colop.filter(img, null); }
--- a/servlet/src/digilib/servlet/Scaler.java Tue Mar 01 22:00:50 2011 +0100 +++ b/servlet/src/digilib/servlet/Scaler.java Fri Mar 04 17:49:15 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.1a16"; + public static final String version = "1.9.1a17"; /** servlet error codes */ public static enum Error {UNKNOWN, AUTH, FILE, IMAGE};