我一直试图弄清楚如何在不使用imageIO库的情况下解码图像BMP 54字节。到目前为止,我的算法在54偏移和我的colorTable之后循环数据没有任何意义。有人能给我一些提示继续吗? THX
static BufferedImage img = null;
private int biWidth;
private int biHeight;
private byte[][] colorTable ;
public ConcreteImage(File path) {
super._path = path;
try{
FileInputStream f = new FileInputStream(super._path);
int content;
int count = 0 ;
while ((content = f.read()) != -1) {
if(count == 18)
biWidth = content;
if(count == 22)
biHeight = content;
if(count > 54){
/*System.out.println(content);*/
colorTable = new byte[biHeight][biWidth];
while((content = f.read()) != -1){
byte rgb[] = new byte[content];
for(int n = 0; n <= biHeight; n++){
for(int j = 0; j <= biWidth; j++){
colorTable[n][j] = rgb[content]; //It points out that i have an error from there.
colorTable[n+1][j+1] = rgb[content+1];
colorTable[n+2][n+2] = rgb[content+2];
}
}
}
System.out.println(colorTable);
}
count++;
}
f.close();