first commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user