// The hash for an image without alpha channel is guaranteed to be // identical for a completely opaque image with alpha. srecord noeq HashBufferedImage(BufferedImage img) { long hash; long get() { if (img == null) ret hash; var gp = grabbableIntPixels_fastOrSlow(img); bool hasAlpha = hasAlpha(img); var ping = pingSource(); int[] pixelsIn = gp.data; int w = gp.w, h = gp.h; int scanlineExtra = gp.scanlineStride-w; int iIn = gp.offset; addToHash(w); addToHash(h); for y to h: { for x to w: { int packed = pixelsIn[iIn++]; if (!hasAlpha) packed |= 0xFF000000; addToHash(packed); } iIn += scanlineExtra; ping?!; } ret hash; } void addToHash(long x) { hash = boostHashCombine64(hash, x); printVars ifdef HashBufferedImage_debug(x := longToHex(x), +hash); } }