bi = (BufferedImage) image;
else
bi = Utilities.toBufferedImage(new DcImageIcon(image), -1, -1);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedOutputStream bos = new BufferedOutputStream(baos);
byte[] bytes = null;
try {
ImageIO.write(bi, (type == DcImageIcon._TYPE_JPEG ? "JPG" : "PNG"), bos);
bos.flush();
bytes = baos.toByteArray();
bi.flush();
} catch (IOException e) {
logger.error(e, e);
}
try {
baos.close();
bos.close();
} catch (IOException e) {
logger.error(e, e);
}
return bytes;