static Image2B resizeImage2B(int w, int h default widthToHeight(w, img), Image2B img) { if (img == null) null; int w1 = img.getWidth(), h1 = img.getHeight(); if (w == w1 && h == h1) ret img; byte[] pixels1 = img.pixels, pixels2 = new byte[(w*h+7)/8]; int i = 0; double y1 = 0, ystep = doubleRatio(h1, h), xstep = doubleRatio(w1, w); for y to h: { int i1 = ifloor(y1)*w1; y1 += ystep; double x1 = 0; for x to w: { int i2 = i1+ifloor(x1); if ((pixels1[i2/8] & (1 << (i2 & 7))) != 0) pixels2[i/8] |= 1 << (i & 7); x1 += xstep; i++; } } ret new Image2B(w, h, pixels2); }