static BWImage invertImageInPlace(BWImage bw) { if (bw != null) { byte[] pixels = bw.pixels; int n = pixels.length; for i to n: pixels[i] = (byte) ~pixels[i]; } ret bw; }