2013-07-19 4 views
3

를 사용하여 캡처 이미지 화면을 메일하는 방법 :이 완벽하게 작동나는 코로나 SDK 새로운 오전,하지만 난 다음 코드를 사용하여 내 응용 프로그램 장면을 캡처 관리했습니다 코로나 SDK

local function captureArea() 
    local myCaptureImage = display.captureBounds(display.currentStage.contentBounds, true) 
    myCaptureImage:removeSelf() 
    myCaptureImage = nil 
end 
bg:addEventListener("tap",captureArea) 

.

이제 캡쳐 된 이미지 (특정 이름 : screen_1.png)를 이메일을 통해 친구에게 보내야합니다. 나는 Composing E-mail and SMS을 사용했지만, 나는이 저장된 이미지를 메일 옵션의 attachment 필드에 어떻게 추가 할 수 있는지 이해하지 못한다.

위의 저장된 이미지를 전자 메일로 첨부하여 보낼 수있는 방법을 알려주십시오.

+0

정말 이니? 캡처 한 이미지를 temproray 디렉토리 또는 문서 디렉토리에 저장 하시겠습니까? 이전에 비슷한 캡처 기능을 수행했지만 captureBounds 함수를 사용하지 않았습니다. view.save (view, "screen_1.png", system.DocumentsDirectory)를 사용해야합니다. 여기서 뷰는 저장하려는 표시 그룹을 나타냅니다. 문서 디렉토리에 저장 한 후, 당신은 전자 메일 작성자 –

+0

@ DoğancanArabacı : 예, 위의 코드가 완벽하게 작동하는 작성을 사용할 수 있습니다. 나는 그것을 시험했다. 그리고 제안 tooooooo에 감사드립니다 ... – Thampuran

답변

1

display.captureBounds은 전체 화면을 디렉토리에 저장하는 데 적합합니다. 그러나 일반적으로 마지막 색인의 증가와 함께 파일을 저장합니다. 따라서 올바르게 읽는 것이 어려울 수 있습니다. 따라서 나는 display.save을 선호합니다. 그러나 그것은 직설적 인 방법이 아닙니다. localgroup을 만들

  • 첫째 :

    는이 일을 위해, 당신은해야합니다.
  • 그런 다음 add 해당 그룹의 화면 개체.
  • Return 표시 그룹
  • 표시되는 전체 그룹을 저장하려면 display.save을 사용하십시오.
  • 메일 옵션을 만들고 baseDirectory
  • 전화 내가 여기에 샘플을 제공하고 mail Popup

에서 attachment 이미지를 추가 :

-- creating the display group -- 
local localGroup = display.newGroup() 

-- creating display objects and adding it to the group -- 
local bg = display.newRect(0,0,_w,_h) 
bg.x = 160 
bg.y = 240 
bg:setFillColor(150) 
localGroup:insert(bg) 

local rect = display.newRect(0,0,50,50) 
rect.x = 30+math.random(260) 
rect.y = 30+math.random(420) 
localGroup:insert(rect) 

-- Then do as follows -- 
local function takePhoto_andSendMail() 
    -- take screen shot to baseDirectory -- 
    local baseDir = system.DocumentsDirectory 
    display.save(localGroup, "myScreenshot.jpg", baseDir) 

    -- Create mail options -- 
    local options = 
    { 
    to = { "[email protected]",}, 
    subject = "My Level", 
    body = "Add this...", 
    attachment = 
    { 
     { baseDir=system.DocumentsDirectory, filename="myScreenshot.jpg", type="image" }, 
    }, 
    } 

    -- Send mail -- 
    native.showPopup("mail", options) 
end 
rect:addEventListener("tap",takePhoto_andSendMail) 

이 그것을 할 것 ...

코딩 유지를 ........ :)

+0

와우. 이게 내가 찾는거야. 덕분에 많은 krs ... – Thampuran