读取24位BMP图像并生成JPG缩略图(一)(4) (255&0xff)<<24 (((int)brgb[nindex+2]&0xff)<<16) (((int)brgb[nindex+1]&0xff)<<8) (int)brgb[nindex]&0xff; nindex+=3; } nindex+=npad; } Toolkit kit=Toolkit.getDefaultToolkit(); image=kit.createImage(new MemoryImageSource(nwidth,nheight, ndata,0,nwidth)); result="从BMP得到图像image"; System.out.println("从BMP得到图像image"); }else{ result="不是24位BMP,失败!"; System.out.println("不是24位BMP,失败!"); image=(Image)null; } fs.close(); //关闭输入流 //开始进行图像压缩(对image对象进行操作) int wideth=image.getWidth(null); //得到源图宽