display.captureScreen() makes blurry captures

The following codes makes a screen capture every second (I use fps = 30):

local counter = 0 local function onEnterFrame(event) counter = counter + 1 if counter%30==0 then display.captureScreen(true) end return true end function scene:enterScene(event) local group = self.view Runtime:addEventListener("enterFrame", onEnterFrame) end scene:addEventListener("enterScene", scene)

The first screen shot is fine. Then, with every further shot, the image moves a bit (1 pixel?) to the left and is kinda overlaying with the image saved before. After just a few seconds, the screen output on the simulator stops completely although the images are still saved (and still get more blurry).

I thought I could use this function to save screen shots continuously and then turn them into a movie.

SDK 2013.1225

One major problem is that the captured images are piling on top of each other onscreen…

You’re taking a screenshot of the first screenshot, and then a screenshot of that… Anyways, it would crash at some point - not too far down the road, given that each screenshot gobbles another chunk of texture memory, up to 16MB per picture (depending on the devices screen rez – but Corona tops out at the captured image size being 2048x2048 pixels).

So replace your screen cap with something like this to remove the freshly captured images, and release them from memory as it goes along

[lua]

    local screenCap = display.captureScreen( true )    – Get a pointer to the new image object

         screenCap:removeSelf()    – remove it from the display

         screenCap = nil                  – Signal the sdk we’re done with this img for now, it can garbage collect the memory

[/lua]

This doesn’t solve some other problems you’re about to run into, though. (I think you’ll be starting a new question soon…)

In particular – it appears you don’t have access to the camera roll files / filenames… In addition to that, if you use content scaling, the captured images are typically much higher resolution than the display itself (even though they were captured from the display!)

But if you tackle the issues one by one… It sounds like it’s perfectly do-able. Best of luck!

Thanks a lot  :)  Work fine now (on the simulator only, no need for me to run that on a real device).

Of course the simulator is very slow now (runs in slow motion if you will), which makes it even easier for recording, since you don’t have to react in real time.

I probably will post some scripts later how the single screen captures can be turned into a movie.

Isn’t there method to just save screen capture without rendering it (so you later unfortunately have to remove it)?

Hi @piotrz55,

I think you may be referring to display.save()? This saves the file but doesn’t render it to the screen.

http://docs.coronalabs.com/api/library/display/save.html

Brent

Yep, I know - it was rather question if @martin189 knows something like it existed (wasn’t sure about function naming)  :slight_smile:

Never mind. To create a movie, it is too slow and too time-consuming anyway.

One major problem is that the captured images are piling on top of each other onscreen…

You’re taking a screenshot of the first screenshot, and then a screenshot of that… Anyways, it would crash at some point - not too far down the road, given that each screenshot gobbles another chunk of texture memory, up to 16MB per picture (depending on the devices screen rez – but Corona tops out at the captured image size being 2048x2048 pixels).

So replace your screen cap with something like this to remove the freshly captured images, and release them from memory as it goes along

[lua]

    local screenCap = display.captureScreen( true )    – Get a pointer to the new image object

         screenCap:removeSelf()    – remove it from the display

         screenCap = nil                  – Signal the sdk we’re done with this img for now, it can garbage collect the memory

[/lua]

This doesn’t solve some other problems you’re about to run into, though. (I think you’ll be starting a new question soon…)

In particular – it appears you don’t have access to the camera roll files / filenames… In addition to that, if you use content scaling, the captured images are typically much higher resolution than the display itself (even though they were captured from the display!)

But if you tackle the issues one by one… It sounds like it’s perfectly do-able. Best of luck!

Thanks a lot  :)  Work fine now (on the simulator only, no need for me to run that on a real device).

Of course the simulator is very slow now (runs in slow motion if you will), which makes it even easier for recording, since you don’t have to react in real time.

I probably will post some scripts later how the single screen captures can be turned into a movie.

Isn’t there method to just save screen capture without rendering it (so you later unfortunately have to remove it)?

Hi @piotrz55,

I think you may be referring to display.save()? This saves the file but doesn’t render it to the screen.

http://docs.coronalabs.com/api/library/display/save.html

Brent

Yep, I know - it was rather question if @martin189 knows something like it existed (wasn’t sure about function naming)  :slight_smile:

Never mind. To create a movie, it is too slow and too time-consuming anyway.