Hello, I smushed the PhotoPicker and ComposeEmailSMS examples together to allow a user to pick an image to upload, then email it. It seems to work perfectly, until the email UI pops up, and the image is cropped! It just shows the lower left corner. I’ve taken out all the rescaling code and it still happens. Is this a bug? (I’m testing it on an iPad Mini, uploading photos I took with the device.)
Here’s the code.
[lua]display.setStatusBar( display.HiddenStatusBar )
local widget = require “widget”
widget.setTheme( “theme_ios” )
local function onSendEmail( event )
– compose an HTML email with a picture attachment
local options =
{
to = { “john.doe@somewhere.com”, },
subject = “HELLO WORLD”,
attachment =
{
{baseDir=system.DocumentsDirectory, filename=“photo.jpg”, type=“image”},
},
}
native.showPopup(“mail”, options)
end
local function UploadPicture( event )---------------------------------------------------------------
local photo – holds the photo object
local PHOTO_FUNCTION = media.PhotoLibrary
local isXcodeSimulator = “iPhone Simulator” == system.getInfo(“model”)
if (isXcodeSimulator) then
local alert = native.showAlert( “Information”, “No Photo Library available on iOS Simulator.”, { “OK”})
end
local bkgd = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
bkgd:setFillColor(0, 200, 255)
local text = display.newText( “Tap to launch Photo Picker”, 0, 0, nil, 16 )
text:setTextColor( 255, 255, 255 )
text.x = display.contentCenterX
text.y = display.contentCenterY
local sessionComplete = function(event)
photo = event.target
if photo then
bkgd.x = 100000 --Hide bkgd
text.text = “”
else
bkgd.x = 100000
text.text = “No Image Selected”
text.x = display.contentCenterX
text.y = display.contentCenterY
print( “No Image Selected” )
end
g=display.newGroup()
g:insert(photo)
display.save(g, “photo.jpg”, system.DocumentDirectory)
g:toBack()
end
– Screen tap comes here to launch Photo Picker
local tapListener = function( event )
display.remove(g) – remove the previous photo object
text.text = “Select a picture …”
text.x = display.contentCenterX
text.y = display.contentCenterY
– Delay some to allow the display to refresh before calling the Photo Picker
timer.performWithDelay( 100, function() media.show( PHOTO_FUNCTION, sessionComplete )
end )
return true
end
bkgd:addEventListener( “tap”, tapListener )
end --END OF UPLOAD PICTURE FUNCTION
-----BUTTONS-----------------------------------------------------------------------
local sendEmail = widget.newButton{
top = 0, left = 0,
label = “Compose Email”,
onRelease = onSendEmail
}
sendEmail.x = display.contentWidth * 0.5
sendEmail.y = display.contentHeight - 100
local uploadPhotoButton = widget.newButton{
top = 0, left = 0,
label = “Upload Picture”,
onRelease = UploadPicture
}
uploadPhotoButton.x = display.contentWidth * 0.5
uploadPhotoButton.y = display.contentHeight - 156[/lua] [import]uid: 191140 topic_id: 34804 reply_id: 334804[/import]
[import]uid: 191140 topic_id: 34804 reply_id: 138836[/import]