srecord noeq BinaryImageToString(IBinaryImage img) { settable S format = "$(width)x$(height)-$(hex)"; simplyCached Image2B renderedImage() { ret img == null ?: img.toImage2B(); } private S lazyReplace(S s, S pattern, IF0 replacement) { if (contains(s, pattern)) s = replace(s, pattern, strOrEmpty(replacement!)); ret s; } 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)", -> hexPixels()); ret s; } S hexPixels() { var img = this.renderedImage(); byte[] pixels = img.pixels; int n = pixels.length; while (n > 1 && pixels[n-1] == 0) --n; ret bytesToHex(pixels, 0, n); } }