问下面的两个方法是实现什么功能,知道的告诉一下
public static int constructInt(byte[] in, int offset) { int ret = ((int) in[offset + 3] & 0xff); ret = (ret << 8) | ((int) in[offset + 2] & 0xff); ret = (ret << 8) | ((int) in[offset + 1] & 0xff); ret = (ret << 8) | ((int) in[offset + 0] & 0xff); return (ret); }protected static Image readMap24(FileInputStream fs, BitmapHeader bh)
throws IOException { Image image; int npad = (bh.nsizeimage / bh.nheight) - bh.nwidth * 3; int ndata[] = new int[bh.nheight * bh.nwidth]; byte brgb[] = new byte[(bh.nwidth + npad) * 3 * bh.nheight]; fs.read(brgb, 0, (bh.nwidth + npad) * 3 * bh.nheight); int nindex = 0; for (int j = 0; j < bh.nheight; j++) { for (int i = 0; i < bh.nwidth; i++) { ndata[bh.nwidth * (bh.nheight - j - 1) + i] = constructInt3(
brgb, nindex); nindex += 3; } nindex += npad; } image = Toolkit.getDefaultToolkit().createImage (new MemoryImageSource(bh.nwidth, bh.nheight, ndata, 0, bh.nwidth)); fs.close(); return (image); }
public static int constructInt(byte[] in, int offset) { int ret = ((int) in[offset + 3] & 0xff); ret = (ret << 8) | ((int) in[offset + 2] & 0xff); ret = (ret << 8) | ((int) in[offset + 1] & 0xff); ret = (ret << 8) | ((int) in[offset + 0] & 0xff); return (ret); }protected static Image readMap24(FileInputStream fs, BitmapHeader bh)
throws IOException { Image image; int npad = (bh.nsizeimage / bh.nheight) - bh.nwidth * 3; int ndata[] = new int[bh.nheight * bh.nwidth]; byte brgb[] = new byte[(bh.nwidth + npad) * 3 * bh.nheight]; fs.read(brgb, 0, (bh.nwidth + npad) * 3 * bh.nheight); int nindex = 0; for (int j = 0; j < bh.nheight; j++) { for (int i = 0; i < bh.nwidth; i++) { ndata[bh.nwidth * (bh.nheight - j - 1) + i] = constructInt3(
brgb, nindex); nindex += 3; } nindex += npad; } image = Toolkit.getDefaultToolkit().createImage (new MemoryImageSource(bh.nwidth, bh.nheight, ndata, 0, bh.nwidth)); fs.close(); return (image); }
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货