[摘要](int)brgb[nindex]&0xff; // System.out.println("Encoded Color at (" +i+",...
(int)brgb[nindex]&0xff;
// System.out.println("Encoded Color at ("
+i+","+j+")is:"+nrgb+" (R,G,B)= ("
+((int)(brgb[2]) & 0xff)+","
+((int)brgb[1]&0xff)+","
+((int)brgb[0]&0xff)+")");
nindex += 3;
}
nindex += npad;
}
image = createImage
( new MemoryImageSource (nwidth, nheight,
ndata, 0, nwidth));
}
else if (nbitcount == 8)
{
// 必须确定颜色数。如果 clrsused 参数大于 0,
// 则颜色数由它决定。如果它等于 0,则根据
// bitsperpixel 计算颜色数。
int nNumColors = 0;
if (nclrused > 0)
{
nNumColors = nclrused;
}
else
{
nNumColors = (1&0xff)<<nbitcount;
}
System.out.println("The number of Colors is"+nNumColors);
// 某些位图不计算 sizeimage 域,请找出
// 这些情况并对它们进行修正。
if (nsizeimage == 0)
{
nsizeimage = ((((nwidth*nbitcount)+31) & ~31 ) >> 3);
nsizeimage *= nheight;
System.out.println("nsizeimage (backup) is"+nsizeimage);
}
// 读取调色板颜色。
int npalette[] = new int [nNumColors];
byte bpalette[] = new byte [nNumColors*4];
fs.read (bpalette, 0, nNumColors*4);
int nindex8 = 0;
for (int n = 0; n < nNumColors; n++)
{
npalette[n] = (255&0xff)<<24
关键词:Java应用程序中加载位图文件的逐步向导