is the object created from display.capture a regular display object?

I’m guessing no, because when I try to add it to scene.view it gives me an error.

My use case is that I am creating a minimap by constructing a map out of small images, then shrinking the map with object.scale and taking a picture of it with display capture before returning it to full size.

I’m doing this because the map configuration is random, but it is saved and you can come back to it later. I want the minimap image as an icon for the button referencing the map.

Appart from the timers required to allow the change in scale to complete and do the capture, this works, and I get an object that I can move around the screen. I assign it to a module variable and later I try to save it to a file… And the emulator crashes with no error messages.

So, I’m trying to figure out why it’s crashing and how to save this minimap image without crashing the program.

Any advice? [import]uid: 191108 topic_id: 35024 reply_id: 335024[/import]

What errors are you getting? [import]uid: 199310 topic_id: 35024 reply_id: 139261[/import]

I’m not getting any errors, it is just crashing to desktop.

That’s what is making it so hard to diagnose. [import]uid: 191108 topic_id: 35024 reply_id: 139279[/import]

Hi Mark,
The captured object you get is a normal display object. That part seems to be working, so I’m guessing this is something in your file save code. Can you try to isolate the code where you do this and post it here within <code> tags?

Thanks,
Brent [import]uid: 200026 topic_id: 35024 reply_id: 139297[/import]

see comment below for function where it is actually causing the crash

local miniMap  
  
local function updateMiniMap()  
 local group = scene.view  
 local function saveImage()  
 miniMap = display.capture(currentMap)  
 currentMap.xScale, currentMap.yScale = 1, 1  
 miniMap.x, miniMap.y = 40, 40  
 group:insert(miniMap)  
 return miniMap  
 end  
 currentMap.xScale, currentMap.yScale = .02, .02  
 timer.performWithDelay(100, saveImage)  
end  
  
-- this is where it is crashing the emulator  
local function saveMapIcon()  
 local fileName = mapFile .. ".jpg"  
 local path = system.pathForFile( fileName, system.DocumentsDirectory)  
 display.save(miniMap, path)  
end  

saveMapIcon is being called right before I switch scenes, if that matters. I call that function and then I call the gotoScene function.

I’m working on a Vista machine.

mapFile is a unique id generated from time and some other encoding
miniMap is my captured display object, it is a local

I’m almost convinced that this process is a bad one, shrinking the map and then expanding it is pretty noticable since it requires a delay to work properly. I think I am just going to create a second map that is tiny instead of shrinking the main one. [import]uid: 191108 topic_id: 35024 reply_id: 139337[/import]

Hi Mark,
Have you worked through the Corona sample project “Storage > ScreenCaptureToFile”? This shows how to do all the display capture/save stuff. I suggest working backwards from this sample and seeing if maybe you can accomplish what you need based on that template.

Brent [import]uid: 200026 topic_id: 35024 reply_id: 139367[/import]

I looked at that app. It’s doing things a bit different as it is not using display.capture

I will say that it is responding much faster than it is in my app. I had been trying to use display.save to save a copy right before the transition back to the menu screen but it seems that all I would get is a black square. I assume it was because the display object was already off the screen by the time the code executed. [import]uid: 191108 topic_id: 35024 reply_id: 139376[/import]

What errors are you getting? [import]uid: 199310 topic_id: 35024 reply_id: 139261[/import]

I’m not getting any errors, it is just crashing to desktop.

That’s what is making it so hard to diagnose. [import]uid: 191108 topic_id: 35024 reply_id: 139279[/import]

Hi Mark,
The captured object you get is a normal display object. That part seems to be working, so I’m guessing this is something in your file save code. Can you try to isolate the code where you do this and post it here within <code> tags?

Thanks,
Brent [import]uid: 200026 topic_id: 35024 reply_id: 139297[/import]

see comment below for function where it is actually causing the crash

local miniMap  
  
local function updateMiniMap()  
 local group = scene.view  
 local function saveImage()  
 miniMap = display.capture(currentMap)  
 currentMap.xScale, currentMap.yScale = 1, 1  
 miniMap.x, miniMap.y = 40, 40  
 group:insert(miniMap)  
 return miniMap  
 end  
 currentMap.xScale, currentMap.yScale = .02, .02  
 timer.performWithDelay(100, saveImage)  
end  
  
-- this is where it is crashing the emulator  
local function saveMapIcon()  
 local fileName = mapFile .. ".jpg"  
 local path = system.pathForFile( fileName, system.DocumentsDirectory)  
 display.save(miniMap, path)  
end  

saveMapIcon is being called right before I switch scenes, if that matters. I call that function and then I call the gotoScene function.

I’m working on a Vista machine.

mapFile is a unique id generated from time and some other encoding
miniMap is my captured display object, it is a local

I’m almost convinced that this process is a bad one, shrinking the map and then expanding it is pretty noticable since it requires a delay to work properly. I think I am just going to create a second map that is tiny instead of shrinking the main one. [import]uid: 191108 topic_id: 35024 reply_id: 139337[/import]

Hi Mark,
Have you worked through the Corona sample project “Storage > ScreenCaptureToFile”? This shows how to do all the display capture/save stuff. I suggest working backwards from this sample and seeing if maybe you can accomplish what you need based on that template.

Brent [import]uid: 200026 topic_id: 35024 reply_id: 139367[/import]

I looked at that app. It’s doing things a bit different as it is not using display.capture

I will say that it is responding much faster than it is in my app. I had been trying to use display.save to save a copy right before the transition back to the menu screen but it seems that all I would get is a black square. I assume it was because the display object was already off the screen by the time the code executed. [import]uid: 191108 topic_id: 35024 reply_id: 139376[/import]