static BWImage bwInverted(BWImage bw) { if (bw == null) ret bw; int w = bw.getWidth(), h = bw.getHeight(); BWImage bw2 = new BWImage(w, h); for y to h: for x to w: bw2.setInt(x, y, 255-bw.getInt(x, y)); ret bw2; }