1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
public static ByteArrayInputStream getBlobByImage(Image image) {
if (image!=null) {
BufferedImage buff = ImageUtils.toBufferedImage(image);
byte[] imageBytes;
if(buff != null) {
BufferedImage bImage = (BufferedImage)buff;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
ImageIO.write(bImage, "gif", baos);
//PROBLEME ICI PUSIQUE L'OUTPUTSTREAM EST DE TAILLE 0
} catch (IOException e) {
throw new IllegalStateException(e.toString());
}
imageBytes = baos.toByteArray();
} else {
imageBytes = new byte[0];
cat.debug("PCD error : the buffered image is null");
}
ByteArrayInputStream inStream = new ByteArrayInputStream(imageBytes);
return inStream;
} else {
cat.debug("PCD error : the image is null");
byte[] imageNullBytes = new byte[0];
return new ByteArrayInputStream(imageNullBytes);
}
} |