Use save(); in the background

When i want to use the save function, the programm lags for a few milliseconds, can i make it so it does it in the background?

1 Like

Hi @Lissie,

What exactly do you try to achieve?
The save or saveframe functions are meant to save the current window content, resp graphics buffer to a image file. Usually this is used to save a screenshot for the first or to save all the frames for the latter to ie. create a video from the frames. Both shouldn’t be time critical actions so the lagging shouldn’t be a problem…

Cheers
— mnse

3 Likes

hint(ENABLE_ASYNC_SAVEFRAME);

2 Likes

im making a programm with an undo function. it needs to save an image and while its saving still track mouse movement & check variables!
Cheers

Two thoughts:

  • instead of save to Hard Drive you could save to a PGraphics with get() - might be faster. Then you can undo from there. You could even store in an array.
  • you could use thread() for a new process/thread
3 Likes

yep that worked! thank man!
I used thread. if you want to use it in a class make a “public void yourthread()” and in the class write “thread(“yourthread”);” if you want to use variables or PImages or anything that only exists in the class, make a getter method (you dont need to make a new variable in the main part, just use “theclass.getVariableOne()” in for example “rect(theclass.getVariableOne(),10,10,10);” i hope this helps all of you who want to make a drawing app, text editing app or anything!

1 Like