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 = s.replace(pattern, 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)", -> hex()); ret s; } S hexPixels() { var img = this.renderedImage(); int n = img.getWidth()*img.getHeight(); byte[] pixels = img.pixels; while (n > 0 && pixels[n-1] == 0) --n; ret bytesToHex(pixels, 0, n); } }