我想在我的(iOS)應用程序中有一個按鈕,它會截取當前屏幕的屏幕截圖,然後將其附加到短信。cocos-2d captureScreen C++ - 如何使用或保存捕獲的圖像?
就像我在這個其他應用程序所看到的......
我有消息發送的工作,我想我有截圖的工作,但我不知道在哪裏截圖保存或如何使用它。
我的消息發送是從應用程序的按鈕叫...
void GameOverScene::messageCallBack(cocos2d::Ref *sender) {
CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(ALL_BUTTONS_CLICK_SOUND_NAME);
utils::captureScreen(CC_CALLBACK_2(GameOverScene::afterCaptured, this), "screenshot.png");
__String *messageTextOne = __String::create("sms:&body=Hey,%20I%20just%20hit%20a%20score%20of%20");
__String *messageTextTwo = __String::createWithFormat("%i", score);
__String *messageURL = __String::createWithFormat("%s%s", messageTextOne->getCString(), messageTextTwo->getCString());
Application::getInstance()->openURL(messageURL->getCString());
}
和截圖功能是...
void GameOverScene::afterCaptured(bool succeed, const std::string &outputFile) {
if (succeed) {
log("Screen capture succeeded");
Size screenSize = Director::getInstance()->getWinSize();
RenderTexture * tex = RenderTexture::create(screenSize.width, screenSize.height);
tex->setPosition(screenSize.width/2, screenSize.height/2);
tex->begin();
this->getParent()->visit();
tex->end();
tex->saveToFile("Image_Save.png", Image::Format::PNG);
} else {
log("Screen capture failed");
}
}
我得到在控制檯消息「截屏成功「,我的消息應用程序打開預填的文本消息。
我需要做的是添加屏幕截圖到這條消息,但我不知道該怎麼做,或屏幕截圖保存的位置,或者如何使用保存的屏幕截圖。
我最終想與這個畫面做的是將其發送到iPhone的消息應用程序,因此它可以作爲一個被髮送出去文本。我將如何去截圖發送消息? – Richard
試試這個:http://stackoverflow.com/questions/21699756/send-picture-text-in-imessage-in-ios-programatically – Makalele