static BWImage decolorizeImage(Decolorizer decolorizer, BufferedImage image) { if (image == null) null; var gp = grabbableIntPixels_fastOrSlow(image); if (gp == null) null; var ping = pingSource(); int[] pixelsIn = gp.data; int w = gp.w, h = gp.h; int scanlineExtra = gp.scanlineStride-w; int iIn = gp.offset, iOut = 0; byte[] pixelsOut = new[w*h]; for y to h: { for x to w: { int packed = pixelsIn[iIn++]; int brightness = decolorizer.toGrayScale(packed); pixelsOut[iOut++] = (byte) brightness; } iIn += scanlineExtra; ping?!; } ret BWImage(w, h, pixelsOut); } static BWImage decolorizeImage(BufferedImage image, Decolorizer decolorizer) { ret decolorizeImage(decolorizer, image); }