16,471
社区成员
发帖
与我相关
我的任务
分享
private int[] getPalette(InputStream is) throws IOException {
byte[] paletteBytes = new byte[1024];// 传说中的调色板
is.read(paletteBytes);
int colors = 256;// 256色的调色板
int npalette[] = new int[colors];
int nindex8 = 0;
for (int n = 0; n < colors; n++) {
npalette[n] = (255 & 0xff) << 24
| (((int) paletteBytes[nindex8 + 2] & 0xff) << 16)
| (((int) paletteBytes[nindex8 + 1] & 0xff) << 8)
| (int) paletteBytes[nindex8] & 0xff; nindex8 += 4;
}// for
return npalette;
}