Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How can open the .jpg/png file just captured by system's photo viewer of users' choice
Started by ask.frankie Apr 20 2017 09:33 PM

- - - - -
2 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

ask.frankie

[GLOBAL: userInfoPane.html]
ask.frankie
  • Observer

  • 6 posts
  • Corona SDK

Dear all experts,

 

As I have use the following code to capture the display screenshot to a .jpg file, 

=========================================

local baseDir = system.DocumentsDirectory

display.save( ScreenGroup, "CapScreen.jpg", baseDir, display.contentCenterX, display.contentCenterY )
local image = display.newImage( "CapScreen.jpg", baseDir )
media.show(media.PhotoLibrary)
=========================================
 
then, I would like to use media.show function to open this "CapScreen.jpg" file by system photo viewer of users' choice.
however, the function will ask user to open system photo viewer only. It won't help me to open the  "CapScreen.jpg" file. Please help... I have also tested media.selectPhoto function. but also not I want.
 
Do anyone have sample code for doing this? thx
 
Best regards
Frankie
 


[TOPIC: post.html]
#2

benzppcrazyman

[GLOBAL: userInfoPane.html]
benzppcrazyman
  • Observer

  • 5 posts
  • Corona SDK

I think you need to save your captured screen image to your Photo Library first.

 

Check this out:

https://docs.coronalabs.com/api/library/display/capture.html

 

Try to change

display.save( ScreenGroup, "CapScreen.jpg", baseDir, display.contentCenterX, display.contentCenterY )

to something like this

local ss = display.capture( ScreenGroup, { saveToPhotoLibrary=true, captureOffscreenArea=true } )


[TOPIC: post.html]
#3

Brent Sorrentino

[GLOBAL: userInfoPane.html]
Brent Sorrentino
  • Moderator

  • 8,161 posts
  • Corona Staff

Hi @ask.frankie,

As suggested, it looks like your syntax is incorrect. The second argument must be a Lua table containing the options for the "display.save()" call, but you have them simply listed as second, third, fourth, and fifth options. That won't work.

 

Please see the documentation on how the API should be called:

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

 

Best regards,

Brent




[topic_controls]
[/topic_controls]