28 lines
730 B
Java
28 lines
730 B
Java
package net.sf.jasperreports.engine.util;
|
|
|
|
import java.awt.Image;
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.IOException;
|
|
import java.io.InputStream;
|
|
import javax.imageio.ImageIO;
|
|
import net.sf.jasperreports.engine.JRException;
|
|
|
|
public class JRJdk14ImageReader implements JRImageReader {
|
|
public Image readImage(byte[] bytes) throws JRException {
|
|
InputStream bais = new ByteArrayInputStream(bytes);
|
|
Image image = null;
|
|
try {
|
|
image = ImageIO.read(bais);
|
|
} catch (Exception e) {
|
|
throw new JRException(e);
|
|
} finally {
|
|
try {
|
|
bais.close();
|
|
} catch (IOException e) {}
|
|
}
|
|
if (image == null)
|
|
throw new JRException("Image read failed.");
|
|
return image;
|
|
}
|
|
}
|