Hi,
I took the sample from Corona where they take a picture with the camera and modified it with using the display.capture and save. It lets me take a picture with the camera but then it just shows the captured picture. After the display.save line I have a showAlert which does not come up. Why is this? How can I use this to take a picture, save it and then continue on?
I must have the events wrong or something because no matter what method I use for trying to save an image the app never continues. I really need some help and am at the point to pay for this if you can help me.
Thanks!
Warren
--
-- Abstract: Camera sample app
--
-- Version: 1.2
--
-- Updated: September 21, 2011
--
-- Update History:
-- v1.1 Fixed logic problem where it said "session was cancelled".
-- v1.2 Added Android support.
--
-- Sample code is MIT licensed, see http://www.coronalabs.com/links/code/license
-- Copyright (C) 2011 Corona Labs Inc. All Rights Reserved.
---------------------------------------------------------------------------------------
-- Camera not supported on simulator.
local isXcodeSimulator = "iPhone Simulator" == system.getInfo("model")
if (isXcodeSimulator) then
local alert = native.showAlert( "Information", "Camera API not available on iOS Simulator.", { "OK"})
end
--
local bkgd = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
bkgd:setFillColor( 128, 0, 0 )
local text = display.newText( "Tap anywhere to launch Camera", 0, 0, nil, 16 )
text:setTextColor( 255, 255, 255 )
text.x = 0.5 \* display.contentWidth
text.y = 0.5 \* display.contentHeight
local function captureWithDelay()
local capture = display.capture()
display.save(capture,"picture3.jpg",system.TemporaryDirectory)
native.showAlert("Corona", "Saved???")
end
local sessionComplete = function(event)
local image = event.target
print( "Camera ", ( image and "returned an image" ) or "session was cancelled" )
print( "event name: " .. event.name )
print( "target: " .. tostring( image ) )
if image then
-- center image on screen
image.x = display.contentWidth/2
image.y = display.contentHeight/2
local w = image.width
local h = image.height
print( "w,h = ".. w .."," .. h )
timer.performWithDelay( 100, captureWithDelay )
end
end
local listener = function( event )
if media.hasSource( media.Camera ) then
media.show( media.Camera, sessionComplete )
else
native.showAlert("Corona", "Camera not found.")
end
return true
end
bkgd:addEventListener( "tap", listener )
[import]uid: 184193 topic_id: 32742 reply_id: 332742[/import]
[import]uid: 52491 topic_id: 32742 reply_id: 130197[/import]