static BufferedImage scaleBufferedImagePixelated(BufferedImage img, int w, int h) { int w1 = img.getWidth(), h1 = img.getHeight(); int[] pixels1 = pixelsOfBufferedImage(img); int[] pixels = new[w*h]; 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: { pixels[i++] = pixels1[i1+ifloor(x1)]; x1 += xstep; } } ret intArrayToBufferedImage(pixels, w, h); }