// result image is as large as the region's bounds // with black pixels inside and white pixels outside the region srecord noeq RegionToBWImage(IImageRegion region) { settable Rect bounds; BWImage image; settable int bgColor = 0xFF; settable int color = 0x00; run { bounds if null = region.bounds(); int x1 = bounds.x, y1 = bounds.y, w = bounds.w, h = bounds.h, i = 0; byte[] pixels = new[w*h]; if (bgColor != 0) fillArray(pixels, (byte) bgColor); for y to h: for x to w: { if (region.contains(x1+x, y1+y)) pixels[i] = (byte) color; i++; } image = new BWImage(w, h, pixels); } BWImage get() { if (image == null) run(); ret image; } }