How to remove snapshots?

I wonder how I can remove snapshots properly? Just like groups?

  • Daniela

Yes :

local snapshot = display.newSnapshot(w, h)

snapshot:removeSelf()
snapshot = nil    

Thank you for your fast answer!

I have one more question regarding the snapshots. I read you can put images in the snapshot group and later remove the images to free memory. But trying this will delete the images before the snapshot was created. How can this be done properly? Should I use a time delay before removing the images I used to create the snapshots? And if so, what time delay is okay here? It’s not a perfect solution, I guess!? Is there a better way to check if the snapshots are created and THEN deleting the images?

Thx again!

Daniela

@Daniela, I am not sure to understand what you mean. Could you describe your use case scenario .

For your information, when you add something to the snapshot container, the object is automatically render in the framebuffer. The snapshot will be rendered again only if you call invalidate. In that case, the snapshot is rendered only in the next frame.

I tried to put images into the snapshot group and directly after doing this I’ve removed the images (not the snapshot) and the images were not visible in the snapshot because of the removal (display.remove(image)).

Then I used performWithDelay to remove the images (after I have used them for creating the snapshot) with a delay of 10 miliseconds, but the snapshot images still were not visible. Increasing the time from 10 miliseconds to 1000 miliseconds worked and the snapshot is showing the image I put into the snapshot group.

SInce you image is not loaded yet, it will be render in the next frame I believe. You can use a timer (but the timer must be equal to 2 frames minimum to play safe) or you could define an EnterFrame event. You would have to wait for the next frame event before removing your images. Then you can also remove your enterFrame event. If you want to go with a timer,

Thx for the fast tip!!!

Yes :

local snapshot = display.newSnapshot(w, h)

snapshot:removeSelf()
snapshot = nil    

Thank you for your fast answer!

I have one more question regarding the snapshots. I read you can put images in the snapshot group and later remove the images to free memory. But trying this will delete the images before the snapshot was created. How can this be done properly? Should I use a time delay before removing the images I used to create the snapshots? And if so, what time delay is okay here? It’s not a perfect solution, I guess!? Is there a better way to check if the snapshots are created and THEN deleting the images?

Thx again!

Daniela

@Daniela, I am not sure to understand what you mean. Could you describe your use case scenario .

For your information, when you add something to the snapshot container, the object is automatically render in the framebuffer. The snapshot will be rendered again only if you call invalidate. In that case, the snapshot is rendered only in the next frame.

I tried to put images into the snapshot group and directly after doing this I’ve removed the images (not the snapshot) and the images were not visible in the snapshot because of the removal (display.remove(image)).

Then I used performWithDelay to remove the images (after I have used them for creating the snapshot) with a delay of 10 miliseconds, but the snapshot images still were not visible. Increasing the time from 10 miliseconds to 1000 miliseconds worked and the snapshot is showing the image I put into the snapshot group.

SInce you image is not loaded yet, it will be render in the next frame I believe. You can use a timer (but the timer must be equal to 2 frames minimum to play safe) or you could define an EnterFrame event. You would have to wait for the next frame event before removing your images. Then you can also remove your enterFrame event. If you want to go with a timer,

Thx for the fast tip!!!