2017-05-18 12 views
6

मैं अपने (आईओएस) ऐप में एक बटन रखना चाहता हूं जो वर्तमान स्क्रीन का स्क्रीनशॉट लेता है और फिर उसे एक टेक्स्ट संदेश से जोड़ता है।कैप्चर-कोक-2 डी सी ++ में कैप्चरस्क्रीन - कैप्चर की गई छवि का उपयोग या सहेजने के लिए कैसे?

जैसे कि मैंने यह अन्य एप्लिकेशन में देखा है ...

enter image description here

मैं काम कर भेजने के संदेश है, और मुझे लगता है कि मैं स्क्रीनशॉट काम कर रहे है, लेकिन मैं नहीं जानता कि जहां स्क्रीनशॉट सहेजा गया है या इसका इस्तेमाल कैसे करें।

मेरे संदेश भेजने अनुप्रयोग में एक बटन से कहा जाता है ...

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"); 
} 
} 

मैं कंसोल में संदेश मिलता है "स्क्रीन पर कब्जा सफल ", और मेरा संदेश ऐप प्रीफ़िल्ल्ड टेक्स्ट संदेश के साथ खुलता है।

मुझे इस संदेश में स्क्रीनशॉट जोड़ने की क्या ज़रूरत है, लेकिन मैं नहीं देख सकता कि यह कैसे करना है, या जहां स्क्रीनशॉट सहेजा गया है, या सहेजे गए स्क्रीनशॉट का उपयोग कैसे करें।

उत्तर

1

यदि यह सफल हुआ तो यह निजी एप्लिकेशन निर्देशिका में सहेजा गया है। IExplorer जैसे सॉफ़्टवेयर का उपयोग करें, अपना ऐप ढूंढें और यह दस्तावेज़ निर्देशिका के अंदर होना चाहिए। अगर आप इसे फ़ोटो में देखना चाहते हैं तो आपने इसे मैन्युअल रूप से जोड़ दिया है।

इस लक्ष्य को हासिल करने के लिए आपको UIImageWriteToSavedPhotosAlbum

कॉल करनी होगी

देखें: How to save picture to iPhone photo library?

आप AppController.m में एक समारोह बना सकते हैं और इसे यहाँ से उपयोग करना होगा। आप सी ++ से ओबीजेसी कोड को कॉल कर सकते हैं। इसके लिए यूआईएममेज की आवश्यकता है, इसलिए सबसे पहले आपको फ़ाइलपैथ पास करना होगा और इससे यूआईइमेज लोड करना होगा और अंततः गैलरी में जोड़ना होगा।

+0

क्या मैं अंत में इस स्क्रीनशॉट साथ क्या करना चाहते हैं, iPhone संदेश अनुप्रयोग के लिए भेज रहा है तो यह एक के रूप में बाहर भेजा जा सकता है पाठ। मैं संदेशों पर स्क्रीनशॉट भेजने के बारे में कैसे जाउंगा? – Richard

+0

इसे आज़माएं: http://stackoverflow.com/questions/21699756/send-picture-text-in-imessage-in-ios- प्रोग्रामिक रूप से – Makalele

0

आप सहेजे गए छवि के पथ प्राप्त करने के लिए कुछ इस तरह उपयोग कर सकते हैं:

void CustomLayerColor::saveFile(Node*node, std::string fileName, const renderTextureCallback& callBack) { 
    float renderTextureWidth = node->getBoundingBox().size.width; 
    float renderTextureHeight = node->getBoundingBox().size.height;   

    RenderTexture * renderTexture = RenderTexture::create(renderTextureWidth,renderTextureHeight); 
    renderTexture->begin(); 

    node->visit(); 

    renderTexture->end(); 
    renderTexture->saveToFile(fileName, Image::Format::PNG, true,callBack); 
} 

void CustomLayerColor::onSaveFileCallBack(RenderTexture * mRenderTexture, const std::string& savedFileNameWithFullPath) { 

} 
संबंधित मुद्दे