srecord noeq BinaryImageToString(IBinaryImage img) { settable S format = "$(width)x$(height)-$(hex)"; simplyCached Image2B renderedImage() { ret img == null ?: img.toImage2B(); } S get() { if (img == null) null; S s = format; s = lazyReplace(s, "$(width)", -> img.getWidth()); s = lazyReplace(s, "$(height)", -> img.getHeight()); s = lazyReplace(s, "$(hex)", -> hex()); ret s; } S hexPixels() { var img = this.img.toImage2B(); int n = w*h; byte[] pixels = img.pixels; while (n > 0 && pixels[n-1] == 0) --n; ret bytesToHex(pixels, 0, n); } }