How to Save a Screenshot
来源:互联网 发布:浴缸 知乎 编辑:程序博客网 时间:2024/04/30 12:53
How to Save a Screenshot
On v3.2 alpha0, utils::captureScreen()
is added to save a screenshot.
The declaration of utils::captureScreen()
is
1void captureScreen(const std::function<void(bool, const std::string&)>& afterCaptured, const std::string& filename);
- afterCapturedThis function will be called after capturing commands are executed. The boolean return value indicates screenshot is captured successfully or not. The string return value is the path screenshot is saved in.
- filenameThe name of screenshot. It can be just a filename, such as
screenshot.png
. It can also be a resolute path, such as/sdcard/screenshot.png
.
The declaration of utils::captureScreen()
for Lua is:
1cc.utils:captureScreen(capturedHandler, filename)
capturedHandler
This function will be called after capturing commands are executed. The format of the captureHandler as follows:
123local function capturedHandler(succeed, outputFile) --do somethingend
The succeed
return value indicates screenshot is captured successfully or not. The stringoutputFile
value is the path screenshot is saved in.
- filenameThe name of screenshot. It can be just a filename, such as
screenshot.png
. It can also be a resolute path, such as/sdcard/screenshot.png
.
Usage
123456789101112131415161718192021void CaptureScreenTest::afterCaptured(bool succeed, const std::string& outputFile){ if (succeed) { // show screenshot auto sp = Sprite::create(outputFile); addChild(sp, 0, childName); Size s = Director::getInstance()->getWinSize(); sp->setPosition(s.width / 2, s.height / 2); sp->setScale(0.25); } else { log("Capture screen failed."); }}void CaptureScreenTest::capture(){ utils::captureScreen(CC_CALLBACK_2(CaptureScreenTest::afterCaptured, this),"CaptureScreenTest.png");}
123456789101112131415161718local function afterCaptured(succeed, outputFile) if succeed then local sp = cc.Sprite:create(outputFile) layer:addChild(sp, 0, childTag) local winSize = cc.Director:getInstance():getWinSize() sp:setPosition(winSize.width / 2, winSize.height / 2) sp:setScale(0.25) else cclog("Capture screen failed.") endendlocal function onCaptured(tag, sender) cc.Director:getInstance():getTextureCache():removeTextureForKey(fileName) layer:removeChildByTag(childTag) fileName = "CaptureScreenTest.png" cc.utils:captureScreen(afterCaptured, fileName)end
0 0
- How to Save a Screenshot
- How to Save a Screenshot
- How to save a picture (take screenshot) from a camera
- Cocos2d-x How to save ScreenShot ?
- How to screenshot in Linux
- How to save a NSImage as a new file
- How to take screenshot (thumbnail) of a web site with ASP.NET 2.0?
- How to:Save Layout
- How to save a web page as HTML or MHT
- Eclipse rcp : How to save a dirty view
- How to save a gecko from gluing disaster
- How to save content/text of a web page by forcing save-as option
- How to resize a *.jpg image and save the result to a file
- How to save brightness settings?
- How to Install Kali Linux on Android - Tutorial With Screenshot
- How to read and save Images in a Sql Server Database using ADO.NET and C#
- how to save a c++ object in java object and use it
- How do I download or save a YouTube video to my computer?
- android 修改默认时间为24小时格式
- LeetCode008:Valid Number(正则表达式的运用)
- Unix网络编程:大端模式与小端模式(在计算机上) & 发送数据时 的网络字节序的含义
- 虚拟机使用经验
- SSH与VM链接
- How to Save a Screenshot
- uvalive 5721 Activation (概率dp+方程)
- http get post
- HDOJ 4939 Stupid Tower Defense
- HDU 1231 最大连续子序列 DP题解
- 如何判断一个数为无符号数还是有符号数
- WPF中使用VLC播放控件制作多屏同步视频
- php学习笔记3--文件系统的操作(创建、打开及批量删除)
- ECSHOP后台权限分配原理分析