Keep Screen (screen.keep)
Declaration
screen.keep()
Description
Cache the current screen image into a buffer. When calling color picking, color finding, screenshot, image finding functions multiple times, data will be read from the cached buffer instead of the live screen, improving performance.
This is an optimization function for heavy static image processing.
It ONLY affects XXTouch's capture/color functions and does NOT freeze the actual device screen.
Example
-- Loop and sample colors of 6144 points, output to log
t = {}
screen.keep()
for k = 1, 640, 10 do
for j = 1, 960, 10 do
-- format as hex string
t[#t + 1] = string.format("%X", screen.get_color(k, j))
end
end
screen.unkeep()
nLog(t)
Note: Uses nLog
Tips
- Two consecutive
screen.get_colorcalls on the same position may return different values.- Without
screen.keep, a singlescreen.get_colorcall takes about the same time as onescreen.keepcall.- After
screen.keep, about 50 consecutivescreen.get_colorcalls cost roughly the same as a singlescreen.keepcall.