我正在尝试将长度为 128 的字节数组转换为存储在 BufferedImage 中的 32x32 位图。我正在使用以下代码:
private BufferedImage fSP;
public Pattern( byte[] aBitData ) {
if ( aBitData == null ) {
throw new IllegalArgumentException( "Please provide a non-null byte array of length 128: " + aBitData );
}
else if ( aBitData.length != 128 ) {
throw new IllegalArgumentException( "Please provide a non-null byte array of length 128: " + aBitData.length );
}
InputStream in = new ByteArrayInputStream( aBitData );
try {
fSP = ImageIO.read( in );
} catch( IOException e ) {
e.printStackTrace();
}
}
但每次 fSP 出于某种原因设置为空。我不明白为什么会这样。谁能帮帮我?