screenshot questions

I have a couple of questions about display.captureScreen:

  1. Is there a way to capture the image as a predestined name?
  2. Is there a way to not get it to display the image on-screen?

I also have a question about display.save:

  1. Why does it not save it to the directory on the simulator? [import]uid: 147322 topic_id: 27350 reply_id: 327350[/import]
  1. No, although display.save() does allow this IIRC.

  2. You mean you want to save the screen and then not load the saved image on the screen, or you want to save an image without showing it on the screen?

  3. It should save to the sandbox not the project root. Did you check sandbox files? You can get to them from File > Show Project Sandbox

Peach :slight_smile: [import]uid: 52491 topic_id: 27350 reply_id: 111117[/import]

So on the device, for display.save() would it save it to the photo album or somewhere in the app? [import]uid: 147322 topic_id: 27350 reply_id: 111148[/import]

On device or on the simulator display.save can either save to the system.Documents directory (default) or the temporary directory.

You can’t save to your projects root (ie resources) directory [import]uid: 84637 topic_id: 27350 reply_id: 111152[/import]

So where would it end up? Would you be able to access it on the device or just as a resource for your game in the code? If it’s not accessible, how would you save a screenshot with a pre-destined name and it appear in the photos?

@peach: by the way, I solved question number 2. [import]uid: 147322 topic_id: 27350 reply_id: 111174[/import]

@binc, im not sure i fully understand your question.

Display.save saves an image with a filename in either the documents directory or temporary directory.

You can load it from there and display it in your app, and then if you wanted save it to the camera roll from there [import]uid: 84637 topic_id: 27350 reply_id: 111175[/import]

So how do I save it to the camera roll once I have it in the documents directory? [import]uid: 147322 topic_id: 27350 reply_id: 111186[/import]

You would display the image in your app, then use display.captureScreen to save it to the camera roll, http://developer.anscamobile.com/reference/index/displaycapturescreen [import]uid: 84637 topic_id: 27350 reply_id: 111192[/import]

Wouldn’t that just achieve the same thing as starting with display.captureScreen? Or would it save as the name? [import]uid: 147322 topic_id: 27350 reply_id: 111315[/import]

Yes it would be the exact same result. However as you said you then get to name the saved image [import]uid: 84637 topic_id: 27350 reply_id: 111351[/import]

How do I name it?

Also, turns out I didn’t solve question #2. When you call display.captureScreen it displays your image on screen. How do I get it not to do that? [import]uid: 147322 topic_id: 27350 reply_id: 111406[/import]

Can you explain what your trying to do exactly, in clear detail? You seem to be posting bits and pieces of information here and there and it is really really hard to decipher what you are trying to achieve here.

[import]uid: 84637 topic_id: 27350 reply_id: 111409[/import]

Ok, sorry. I’ll do it step by step.

  1. Main Object:
    Saving a screenshot with a pre-destined name in the camera roll. (or desktop)

  2. What I have:

local capture=display.newRoundedRect( 0,0,50,50,10) --making the screenshot button  
capture.alpha=0.5  
capture.isHitTestable=true  
  
local function captureToFile(event)  
if event.numTaps==2 then -- only on double tap  
 local time = os.date("\*t")  
 local hour = time.hour  
 local minute=time.min  
 local second=time.sec  
 local day=time.day  
 local month=time.month  
 local year=time.year  
 local completeTime=(month.."-"..day.."-"..year.."\_@"..hour.."."..minute.."."..second..".jpg") --setting the current time and date as name  
capture.alpha=0 --hide the capture button  
display.save( display.currentStage, completeTime, system.DocumentsDirectory) --save the image in documents directory with pre-destined name  
capture.alpha=1 -- show the capture button  
local myImage=display.newImage(completeTime, system.DocumentsDirectory) -- display the saved image, in response to your advice "display the image and then capture the screen"  
myImage.x, myImage.y=middleX, middleY  
myImage:scale(2,2) -- normal image only fills top corner  
end  
end  
capture:addEventListener( "tap", captureToFile )  
  1. My Minor Question:
    How do you remove the image once you’ve called display.captureScreen, as it displays it on the entire screen?

How would I save the name with the file? [import]uid: 147322 topic_id: 27350 reply_id: 111412[/import]

The way I take a screen shot and save the image is -

local snapshot = display.capture( characterGroup, true )  
snapshot.isVisible = false  

I only capture whats in the characterGroup as I don’t want all the interface items in the screen shot. The isVisible line basically stops the image from displaying on the screen.

Dave [import]uid: 117617 topic_id: 27350 reply_id: 111620[/import]

Will that save the name? [import]uid: 147322 topic_id: 27350 reply_id: 111652[/import]

I don’t think you can save a file in the camera roll with a pre-determined name. This is probably so you don’t overwrite a photo with the same name. I wouldn’t be happy if a app over wirtten one of my photos in my camera roll.

Dave [import]uid: 117617 topic_id: 27350 reply_id: 111661[/import]

Do any of the staff know? (that was pointed at you, Danny :slight_smile: ) [import]uid: 147322 topic_id: 27350 reply_id: 111684[/import]

Nudge :slight_smile: [import]uid: 147322 topic_id: 27350 reply_id: 112076[/import]