我想将WritableRaster转换为字节数组,但无法转换为DataBufferByte
BufferedImage thumbnail = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
thumbnail.createGraphics().drawImage(ImageIO.read(imageFile).getScaledInstance(100, 100, Image.SCALE_SMOOTH),0,0,null);
WritableRaster raster = thumbnail.getRaster();
// throws ClassCastException
// java.awt.image.DataBufferInt cannot be cast to java.awt.image.DataBufferByte
DataBufferByte imgData = (DataBufferByte) raster.getDataBuffer();
byte[] data = imgData.getData();