Author: richard.opalka(a)jboss.com
Date: 2009-12-22 09:22:46 -0500 (Tue, 22 Dec 2009)
New Revision: 11349
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/utils/MimeUtils.java
Log:
[JBPAPP-3300] fixing issue
Modified:
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/utils/MimeUtils.java
===================================================================
---
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/utils/MimeUtils.java 2009-12-22
14:16:55 UTC (rev 11348)
+++
stack/native/branches/jbossws-native-3.1.2/modules/core/src/main/java/org/jboss/ws/core/utils/MimeUtils.java 2009-12-22
14:22:46 UTC (rev 11349)
@@ -22,16 +22,19 @@
package org.jboss.ws.core.utils;
import java.awt.image.BufferedImage;
-import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+import javax.imageio.ImageIO;
+import javax.imageio.ImageReader;
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.ImageOutputStream;
import javax.mail.internet.ContentType;
import javax.mail.internet.MimeMultipart;
import javax.mail.internet.ParseException;
@@ -43,10 +46,6 @@
import org.jboss.wsf.common.IOUtils;
import org.jboss.wsf.common.JavaUtils;
-import com.sun.image.codec.jpeg.JPEGCodec;
-import com.sun.image.codec.jpeg.JPEGImageDecoder;
-import com.sun.image.codec.jpeg.JPEGImageEncoder;
-
/**
* Generic mime utility class.
*
@@ -221,15 +220,18 @@
{
public Object readFrom(InputStream in) {
Object converted = null;
+
try
{
- JPEGImageDecoder dec = JPEGCodec.createJPEGDecoder(in);
- BufferedImage bim = dec.decodeAsBufferedImage();
+ ImageReader decoder =
ImageIO.getImageReadersByFormatName("JPEG").next();
+ ImageInputStream iis = ImageIO.createImageInputStream(in);
+ decoder.setInput(iis);
+ BufferedImage bim = decoder.read(0);
converted = bim;
}
catch (Exception e)
{
- // ignore
+ e.printStackTrace();
}
return converted;
@@ -238,10 +240,12 @@
public void writeTo(Object obj, OutputStream out) {
if(obj instanceof BufferedImage)
{
- JPEGImageEncoder enc = JPEGCodec.createJPEGEncoder(out);
+ ImageWriter encoder =
ImageIO.getImageWritersByFormatName("JPEG").next();
try
{
- enc.encode((BufferedImage)obj);
+ ImageOutputStream ios = ImageIO.createImageOutputStream(out);
+ encoder.setOutput(ios);
+ encoder.write((BufferedImage)obj);
}
catch (IOException e)
{
Show replies by date