When using copyImage() on the framebuffer, it captures the previous frame.
-
CopyImage()
is a great tool if you want to capture and manipulate what is currently displayed on the framebuffer.The problem is that it is not capturing the current frame, it is capturing the one before the current frame. Consider this program:
for t = 0 to 10 loop clear() print(t) update() screenGrab = copyImage(frameBuffer, {0, 0, gWidth(), gHeight()}) drawImage(screenGrab, gWidth() / 2, 0) update() sleep(1) repeat
First it prints a number on the screen, calling
update()
to make sure it is shown.
Then it doescopyImage()
from the framebuffer, and prints the result next to the
previous number so you can compare them.I would expect the same number to show up twice on the screen.
What actually happens is that the number is shown, and next to it is a copy of the previous frame, which is evident since the number shown is one less.
This feels like a bug.
Weirdly enough, adding an extra
update()
after row 4 makes no difference, but adding two extraupdate()
makes the program show the same frame both left and right, like this:for t = 0 to 10 loop clear() print(t) update() update() update() screenGrab = copyImage(frameBuffer, {0, 0, gWidth(), gHeight()}) drawImage(screenGrab, gWidth() / 2, 0) update() sleep(1) repeat
I have shared my example program, ID: NXYUURKD5C
-
Thanks for the report- We're aware of various issues like this, and I've put this in the log for reference. The short answer is that it has to do with how the drawing instructions for each frame are processed internally, which are not necessarily synchronized with what the program is doing.