1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
public String getImageToSring(BufferedImage buff){
String imageString;
if(buff != null) {
BufferedImage bImage = (BufferedImage)buff;
ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
try {
ImageIO.write(bImage, "jpeg", baos);
} catch (IOException e) {
throw new IllegalStateException(e.toString());
}
imageString = (String)baos.toString();
}
else {
imageString = new String("");
System.out.println("PCD error : the buffered image is null");
}
return imageString;
} |
Partager