[stylebook] 08/34: Replace com.sun.image.codec.jpeg with javax.imageio for image encoding.

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Thu Mar 29 10:54:16 BST 2018


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to branch master
in repository stylebook.

commit 12eccd40b869fe756cca881a8071a64397ff1d55
Author: Marcus Better <marcus at better.se>
Date:   Mon Dec 11 09:44:18 2006 +0000

    Replace com.sun.image.codec.jpeg with javax.imageio for image encoding.
---
 build.xml                                           |  4 ----
 src/org/apache/stylebook/printers/ImagePrinter.java | 17 +++++++++++------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/build.xml b/build.xml
index a245ae5..9f2c48e 100644
--- a/build.xml
+++ b/build.xml
@@ -56,9 +56,6 @@ Copyright:
 	  <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 @@ Copyright:
   <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"/>
diff --git a/src/org/apache/stylebook/printers/ImagePrinter.java b/src/org/apache/stylebook/printers/ImagePrinter.java
index b46bbd2..9f25830 100644
--- a/src/org/apache/stylebook/printers/ImagePrinter.java
+++ b/src/org/apache/stylebook/printers/ImagePrinter.java
@@ -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 @@ public class ImagePrinter extends AbstractComponent implements Printer {
             }
         }
 
-        // 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();
     }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/stylebook.git



More information about the pkg-java-commits mailing list