sclass G22BurnIn { int w, h; int[] mask; void processFrame(BufferedImage frame) { int w = frame.getWidth(), h = frame.getHeight(); if (mask == null || this.w != w || this.h != h) { this.w = w; this.h = h; this.mask = new int[w*h]; } // We assume the frame has no transparency var gp = grabbableIntPixels_fastOrSlow(frame); int n = w*h, iMask = 0, iFrame = gp.offset; for y to h: { for x to w: { int fpix = getPixel frame x y mpix <- getPixel theMask x y theMask[iMask++] = ... } } }