[pkg-java] r2843 - in branches/stylebook/feature/debian: .
src/org/apache/stylebook/printers
Marcus Better
marcusb-guest at alioth.debian.org
Mon Dec 11 10:44:19 CET 2006
Author: marcusb-guest
Date: 2006-12-11 10:44:18 +0100 (Mon, 11 Dec 2006)
New Revision: 2843
Modified:
branches/stylebook/feature/debian/build.xml
branches/stylebook/feature/debian/src/org/apache/stylebook/printers/ImagePrinter.java
Log:
Replace com.sun.image.codec.jpeg with javax.imageio for image encoding.
Modified: branches/stylebook/feature/debian/build.xml
===================================================================
--- branches/stylebook/feature/debian/build.xml 2006-12-11 09:43:45 UTC (rev 2842)
+++ branches/stylebook/feature/debian/build.xml 2006-12-11 09:44:18 UTC (rev 2843)
@@ -56,9 +56,6 @@
<property name="build.dest" value="${build.dir}/classes"/>
<property name="src.dir" value="./src"/>
<property name="bin.dir" value="./bin"/>
- <condition property="sun.codec.present" >
- <available classname="com.sun.image.codec.jpeg.JPEGCodec"/>
- </condition>
</target>
<target name="prepare" depends="init">
@@ -88,7 +85,6 @@
<target name="compile2" depends="prepare">
<javac srcdir="${src.dir}" excludes="org/apache/stylebook/processors/XalanProcessor.java" destdir="${build.dest}" debug="${debug}">
<exclude name="**/org/apache/stylebook/processors/XalanProcessor.java"/>
- <exclude name="**/org/apache/stylebook/printers/ImagePrinter.java" unless="sun.codec.present"/>
</javac>
<copy todir="${build.dest}/org/apache/stylebook/data">
<fileset dir="${build.src}/org/apache/stylebook/data"/>
Modified: branches/stylebook/feature/debian/src/org/apache/stylebook/printers/ImagePrinter.java
===================================================================
--- branches/stylebook/feature/debian/src/org/apache/stylebook/printers/ImagePrinter.java 2006-12-11 09:43:45 UTC (rev 2842)
+++ branches/stylebook/feature/debian/src/org/apache/stylebook/printers/ImagePrinter.java 2006-12-11 09:44:18 UTC (rev 2843)
@@ -8,7 +8,9 @@
package org.apache.stylebook.printers;
import org.apache.stylebook.*;
-import com.sun.image.codec.jpeg.*;
+import javax.imageio.*;
+import javax.imageio.plugins.jpeg.*;
+import javax.imageio.stream.*;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
@@ -144,11 +146,14 @@
}
}
- // Write out image (highest quality for jpeg data)
- JPEGEncodeParam jpar=JPEGCodec.getDefaultJPEGEncodeParam(img);
- jpar.setQuality(1,true);
- JPEGImageEncoder jenc=JPEGCodec.createJPEGEncoder(out,jpar);
- jenc.encode(img);
+ // Write out image
+ ImageWriter encoder =
+ (ImageWriter)ImageIO.getImageWritersByFormatName("jpeg").next();
+ ImageWriteParam param = encoder.getDefaultWriteParam();
+ param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
+ param.setCompressionQuality(1);
+ encoder.setOutput(new MemoryCacheImageOutputStream(out));
+ encoder.write(null, new IIOImage(img, null, null), param);
out.flush();
}
More information about the pkg-java-commits
mailing list