Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Screen capture - simulator feature
Started by ubj3d.android Jun 07 2013 06:08 AM

- - - - -
20 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

Wondering why is there no screen capture on the simulator menu ?

 

Everyone needs this (we have to submit various screenshots to Apple at least, right ?).

 

Right now, I am using the display.captureScreen( true ) from code, but this can sometimes be awkward.

 

:rolleyes:



[TOPIC: post.html]
#2

SegaBoy

[GLOBAL: userInfoPane.html]
SegaBoy
  • Contributor

  • 635 posts
  • Corona SDK

Just take grabs from the device???



[TOPIC: post.html]
#3

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

And if I have not all the devices ?



[TOPIC: post.html]
#4

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Corona Geek

  • 1,003 posts
  • Corona SDK

You can also just take a screen capture from the Windows or Mac simulator.  On Windows, the PrintScr key copies your screen to the clipboard -- then you can paste it into an image editing program and crop it.  On Mac, there are a few shortcuts to capture the screen.  Command-Shift-3 captures the screen and immediately saves it to a file on your desktop.

 

- Andrew



[TOPIC: post.html]
#5

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

Yes, but you do not get the exact resolution(s) you need and I guess the print-screen would also capture the phone image + you have some work to do with image adjusting etc.

 

With display.captureScreen( true ) you get exactly what you need.



[TOPIC: post.html]
#6

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

Oh no...

 

Is this is bug or what ?

 

On my laptop (Corona build 1135) I can't zoom in on the simulator as much as on my desktop, and the screenshots are not in the right resolutions (e.g. iPhone 4, max zoom gives a 480x320 !?)



[TOPIC: post.html]
#7

SegaBoy

[GLOBAL: userInfoPane.html]
SegaBoy
  • Contributor

  • 635 posts
  • Corona SDK

Why don't you use the XCode Simulator? Pretty sure it's got a direct screen grab feature.

[TOPIC: post.html]
#8

ubj3d.android

[GLOBAL: userInfoPane.html]
ubj3d.android
  • Contributor

  • 741 posts
  • Corona SDK

I am more used to using Windows and only have MacBook Air, I am not very comfortable using it.



[TOPIC: post.html]
#9

guruk

[GLOBAL: userInfoPane.html]
guruk
  • Contributor

  • 790 posts
  • Corona SDK

i also say,

what be an awesome feature to have a simple screenshot button in the simulator

so whatever device and its size choose, we get the same resolution in our screenshot

without hasseling xcode etc.

should be a piece of cake for our great corona devs to implement that feature into the simulator, or!? :)

 

greets

chris



[TOPIC: post.html]
#10

HyperBeard Games

[GLOBAL: userInfoPane.html]
HyperBeard Games
  • Observer

  • 23 posts
  • Enterprise

We should open a request for this feature!



[TOPIC: post.html]
#11

Alan PlantPot

[GLOBAL: userInfoPane.html]
Alan PlantPot
  • Contributor

  • 917 posts
  • Corona SDK

This has worked for me:

local function screenshot()	

	--I set the filename to be "widthxheight_time.png"
	--e.g. "1920x1080_20140923151732.png"
	local date = os.date( "*t" )
	local timeStamp = table.concat({date.year .. date.month .. date.day .. date.hour .. date.min .. date.sec})
	local fname = display.pixelWidth.."x"..display.pixelHeight.."_"..timeStamp..".png"
	
	--capture screen
	local capture = display.captureScreen(false)

	--make sure image is right in the center of the screen
	capture.x, capture.y = display.contentWidth * 0.5, display.contentHeight * 0.5

	--save the image and then remove
	local function save()
		display.save( capture, { filename=fname, baseDir=system.DocumentsDirectory, isFullResolution=true } )    
		capture:removeSelf()
		capture = nil
	end
	timer.performWithDelay( 100, save, 1)
	       	
	return true               
end


--works in simulator too
local function onKeyEvent(event)
	if event.phase == "up" then
		--press s key to take screenshot which matches resolution of the device
    	    if event.keyName == "s" then
    		screenshot()
    	    end
        end
end

Runtime:addEventListener("key", onKeyEvent)


[TOPIC: post.html]
#12

HyperBeard Games

[GLOBAL: userInfoPane.html]
HyperBeard Games
  • Observer

  • 23 posts
  • Enterprise

I'll give it a try, thanks!



[TOPIC: post.html]
#13

liam99

[GLOBAL: userInfoPane.html]
liam99
  • Observer

  • 19 posts
  • Corona SDK

Hello,

 

I have been trying to use this code to take screenshots of my app. I have inserted it into the main.lua file.

 

The screenshot is taking place, but when I look in my Documents directory, I can't see the images anywhere.



[TOPIC: post.html]
#14

Alan PlantPot

[GLOBAL: userInfoPane.html]
Alan PlantPot
  • Contributor

  • 917 posts
  • Corona SDK

Are you sure it's working? No error messages in the console?

[TOPIC: post.html]
#15

liam99

[GLOBAL: userInfoPane.html]
liam99
  • Observer

  • 19 posts
  • Corona SDK

No errors show up in the console. I added "print("Image Saved")" to the save function, and that pops up in the simulator when I press the S key, but the picture doesn't seem to save.



[TOPIC: post.html]
#16

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Corona Geek

  • 1,003 posts
  • Corona SDK

Are you looking in the right folder?  On Windows, the pictures save to My Pictures\Corona Simulator, not My Documents.

 

EDIT: This would be for display.captureScreen(), which the thread mentioned, but I'm not sure if you're using that are the other code that was suggested.

 

- Andrew



[TOPIC: post.html]
#17

liam99

[GLOBAL: userInfoPane.html]
liam99
  • Observer

  • 19 posts
  • Corona SDK

I can't find the images or a Corona Simulator folder in neither the Documents or Pictures folders.

 

Does anyone using a mac know where these pictures save to?



[TOPIC: post.html]
#18

Alan PlantPot

[GLOBAL: userInfoPane.html]
Alan PlantPot
  • Contributor

  • 917 posts
  • Corona SDK

Ah I see where the confusion lies. They don't go into your documents folder on your Mac/PC. Each project in the simulator has it's own Documents folder. 

 

With the project open in the simulator, go to the menu at the top of the screen:

 

File/Show Project Sandbox

 

That will take you to a folder with a name like "YourProjName-B1V23UYGK50978CVQFVC87SFYUHJ43" and in there is the Documents folder for your app.



[TOPIC: post.html]
#19

jilvir

[GLOBAL: userInfoPane.html]
jilvir
  • Observer

  • 2 posts
  • Corona SDK

Dear Allan Quiztix,

 

I try your code but it did not save to the device... I change the false to true value under the captureScreen and it save to the device but the problem is the filename became Picture#.png where # is the number of picture...

 

I need to capture my screen what ever is there and save in the device with the specific filename I want... I don't want to capture a specific or group of object... I want to capture what ever in the screen at the time I press the button...

 

is there somebody can help?

 

 

thanks...



[TOPIC: post.html]
#20

jilvir

[GLOBAL: userInfoPane.html]
jilvir
  • Observer

  • 2 posts
  • Corona SDK

Sorry Alan QuizTix,

 

I followed what you written where andn it's true you can find it in the documents under sandbox... but my problem where I test it to the device (android phone) I can't see it... may I know when I can see the saved picture? which folder?

 

thanks...



[TOPIC: post.html]
#21

csavalas

[GLOBAL: userInfoPane.html]
csavalas
  • Contributor

  • 108 posts
  • Corona SDK

In order to make this work for iOS devices in the simulator on Windows, change the event listener to detect an accelerometer shake. iOS on the windows simulator does not support keyboard key events. To simulate a shake, press [CTRL]+I. Hope that helps.

local function onShake (event)
    if event.isShake then
    	screenshot()
    end
end

Runtime:addEventListener("accelerometer", onShake)



[topic_controls]
[/topic_controls]