public static byte[] getBytes(DcImageIcon icon, int type) {
return getBytes(icon.getImage(), type);
}
public static byte[] getBytes(Image image, int type) {
BufferedImage bi;
if (image instanceof BufferedImage)
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 {