// uses the region's bounds for the imgae srecord noeq RegionToBWImage(IImageRegion region) { Rect bounds; BWImage image; run { bounds = region.bounds(); int x1 = bounds.x, y1 = bounds.y, w = bounds.w, h = bounds.h; byte[] pixels = new[w*h]; for y to h: for x to w: pixels[i] = region.contains(x1+x, y1+y) ? 0 : 0xFF; image = new BWImage(w, h, pixels); } BWImage get() { if (image == null) run(); ret image; } }