Camera saving at screen resolution, other camera-bugs?

Oh, so many problems here!

  1. Pictures taken using the camera are not saving at full resolution.

a) If “captureToFile” is true, then “media.capturePhoto” writes the image to disk, then we add that image to the iPhone photos, but the image is NOT full resolution.

B) If “captureToFile” is false, we save the display objects created by media.capturePhoto…and the image is NOT full resolution.

  1. The camera feed works wonderfully…until I tap the “Take Picture” and launch the native camera interface. Once that happens, the feed stops. If I suspend the app (tap the home button), then start it again, the camera does refresh.

Please help!

  • I wish to take full-resolution photos.

  • I really wish I could trigger a full-resolution camera photo directly from Corona (not by tapping in the native interface).

    –====================================================================-- local widget = require ( “widget” ) local margin = { top = 20, left = 20, bottom = 280, right = 20, } local navbarHeight = 50 display.setStatusBar( display.HiddenStatusBar ) – ------------------------------------------ – Camera view window – ------------------------------------------ --local view = display.newRect(0, 0, display.contentWidth - (margin.left + margin.right), display.contentHeight - (margin.top + margin.bottom) ) local view = display.newRect(0, 0, 4 * (display.contentWidth - (margin.left + margin.right) ), 4 * (display.contentHeight - (margin.top + margin.bottom)) ) view:scale( 0.25, 0.25 ) view:setFillColor(1,1,1) view.anchorX, view.anchorY = 0,0 view.x = margin.left view.y = margin.top view.strokeWidth = 2 view:setStrokeColor(0,0,0, 1) view.fill = { type = “camera” } – Keep updating this view from the camera display.setDrawMode( “forceRender” ) ------------------------------------------------------------ – Take Photo ------------------------------------------------------------ local photoFileCounter = 1 local fn = “photo-”…photoFileCounter…".jpg" local function saveLivePhoto() display.save( view, { filename= fn, baseDir=system.TemporaryDirectory, isFullResolution=true } ) media.save( fn, system.TemporaryDirectory ) photoFileCounter = photoFileCounter + 1 fn = “photo-”…photoFileCounter…".jpg" --native.showAlert( “Corona”, "Saved "…fn … " : " … view.width … ", " … view.height, { “OK” } ) end local captureToFile = false local function photoTaken(event) local photo = event.target if (event.completed) then print (“Picture taken #”…photoFileCounter) print ( "Saved "…fn … " : " … photo.width … ", " … photo.height ) if (not captureToFile) then display.save( photo, { filename= fn, baseDir=system.TemporaryDirectory, isFullResolution=true } ) end media.save( fn, system.TemporaryDirectory ) native.showAlert( “Corona”, "Saved “…fn … " : " … photo.width … “, " … photo.height, { “OK” } ) photoFileCounter = photoFileCounter + 1 fn = “photo-”…photoFileCounter…”.jpg” – Contrary to the documentation, we do end up with an image display on object! event.target:removeSelf() event.target = nil – Native camera will have stopped this, so we must restart Runtime:addEventListener( “enterFrame”, view ); end end local function capturePhoto() if media.hasSource( media.Camera ) then if (captureToFile) then print ("capturePhoto: Save to "…fn) media.capturePhoto( { listener = photoTaken, destination = { baseDir = system.TemporaryDirectory, filename= fn, type=“image” } } ) else media.capturePhoto( { listener = photoTaken } ) end else print (“No camera”) native.showAlert( “Corona”, “This device does not have a camera.”, { “OK” } ) end end if ( system.getInfo(“environment”) ~= “simulator” ) then – Selfie display.setDefault( “cameraSource”, “front” ) --front-facing camera – Front camera --display.setDefault( “cameraSource”, “back” ) --back-facing camera end local buttonY = display.contentHeight - 40 ------------------------------------------------------------ – shapes & example picture ------------------------------------------------------------ local snapButton = widget.newButton { label = “Take Picture”, labelColor = { default = { 1, 1, 1 }, }, fontSize = 36, emboss = true, onPress = capturePhoto, shape = “roundedRect”, width = 500, fillColor = { default={ .2, 0.2, 0.5, 0.7 }, over={ 1, 0.2, 0.5, 1 } }, } snapButton.x = display.contentCenterX snapButton.y = buttonY buttonY = buttonY - 60 local snapButton2 = widget.newButton { label = “Save Display Object”, labelColor = { default = { 1, 1, 1 }, }, fontSize = 36, emboss = true, onPress = saveLivePhoto, shape = “roundedRect”, width = 500, fillColor = { default={ .2, 0.2, 0.5, 0.7 }, over={ 1, 0.2, 0.5, 1 } }, } snapButton2.x = display.contentCenterX snapButton2.y = buttonY buttonY = buttonY - 60

OK, I solved some problems. I figured out how to get the right resolution — the rect you declare to capture the photo using object.fill must be the desired output size. If you want a large picture, you need a large rect. And, it must be visible.

I’m trying again with snapshots, to see if that works.

However, I still need help! Biggest problem: after taking a snapshot using the camera interface, the object.fill stops updating!

OK, I solved some problems. I figured out how to get the right resolution — the rect you declare to capture the photo using object.fill must be the desired output size. If you want a large picture, you need a large rect. And, it must be visible.

I’m trying again with snapshots, to see if that works.

However, I still need help! Biggest problem: after taking a snapshot using the camera interface, the object.fill stops updating!