当前位置:网站首页>【Cocos2d-x】截图分享功能
【Cocos2d-x】截图分享功能
2022-06-23 04:21:00 【linchaolong】
Cocos2d-x截图实现
#include "cocos2d.h"
USING_NS_CC;
// 设置纹理宽、高、像素质量
CCRenderTexture* tx = CCRenderTexture::create(CCDirector::sharedDirector()->getWinSize().width,
CCDirector::sharedDirector()->getWinSize().height,
kCCTexture2DPixelFormat_RGBA8888);
tx->begin();
CCDirector::sharedDirector()->getRunningScene()->visit();
tx->end();
tx->saveToFile(path, kCCImageFormatPNG);
Android下分享一张图片
Intent shareIntent = new Intent(Intent.ACTION_SEND);
//shareIntent.putExtra(Intent.EXTRA_TEXT, 文本);
String imgPath = 图片路径;
File file = new File(imgPath);
if (file.exists()) {
try {
//一般情况下,保存的图片文件权限为rw- rw- rw-(外部可读写),但有的机型可能是rw- --- ---(外部不可读写),如果是后者会分享失败,因为外部不能读取这张图片。为了保证正常分享,需要通过chmod命令修改图片文件的权限。
// 修改文件权限为-rw-r--r--,外部可读
Process p = Runtime.getRuntime().exec("chmod 644 "+imgPath);
int status = p.waitFor(); //让当前线程等待
if (status == 0) { // 返回0表示正常终止
Log.d(TAG, "chmod succeed");
} else {
Log.d(TAG, "chmod failure");
}
} catch (Exception e) {
e.printStackTrace();
}
Uri uri = Uri.fromFile(file);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.setType("image/png");
startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.SHARE)));
}

linux系统下的文件权限
一般情况下android下的每一个应用程序都是一个独立的用户,对应一个独立的组。一个文件的权限由3组3个二进制位表示。
位置0 | - 代表文件 d 代表目录 |
位置1-3(当前用户) | r 可读;w 可写;x 可执行 |
位置4-6(当前用户所在的组) | r 可读;w 可写;x 可执行 |
位置7-9(其他用户的权限) | r 可读;w 可写;x 可执行 |
-代表0
d、r、w、x都是代表1
如:rw-r--r--表示当前用户可读可写,用户所在组可读,其他用户可读。对应的十进制值为 6 4 4。边栏推荐
- The author believes that the so-called industrial Internet is a process of deep integration of industry and the Internet
- PAT 乙等 1010 C语言
- jvm-02.有序性保证
- How to specify the output path of pig register Project Log
- 使用链表实现两个多项式相加和相乘
- Real MySQL interview questions (XXVII) -- Classification of users by RFM analysis method
- MySQL面试真题(二十四)——行列互换
- PAT 乙等 1014 C语言
- Pit filling for abandoned openssl-1.0.2 (.A to.So)
- Kotlin Android simple activity jump, simple combination of handler and thread
猜你喜欢

数字藏品——新的投资机遇

What benefits have digital collections enabled the real industry to release?

MySQL面试真题(二十二)——表连接后的条件筛选及分组筛选

android Handler内存泄露 kotlin内存泄露处理

数字藏品到底有什么魔力?目前有哪些靠谱的团队在开发

Use of visdom
![[Stanford Jiwang cs144 project] lab2: tcpreceiver](/img/70/ceeca89e144907226f29575def0e4d.png)
[Stanford Jiwang cs144 project] lab2: tcpreceiver

ant使用总结(二):相关命令说明

Alibaba cloud object storage oss+picgo+typera implements the construction map

HierarchyViewer工具找不到 HierarchyViewer位置
随机推荐
Three most advanced certifications, two innovative technologies and two outstanding cases, Alibaba cloud appeared at the cloud native industry conference
jvm-06.垃圾回收器
jvm-02.有序性保证
[OWT] OWT client native P2P E2E test vs2017 build 6: modify script automatic generation vs Project
True question of MySQL interview (29) -- case - finding favorite movies
Pat class B 1014 C language
ant使用总结(二):相关命令说明
Oracle exception
【开源项目】excel导出lua配置表工具
Advanced Mathematics (Seventh Edition) Tongji University exercises 1-9 personal solutions
数字藏品——新的投资机遇
Huawei's software and hardware ecosystem has taken shape, fundamentally changing the leading position of the United States in the software and hardware system
Software design and Development Notes 2: serial port debugging tool based on QT design
Excel sheet column title for leetcode Title Resolution
Heimdall database proxy scale out 20 times
Visdom draws multiple dynamic loss curves
Pat class B 1015 C language
数字化工厂建设可划分为三个方面
PAT 乙等 1026 程序运行时间
Analysis on the problems and causes of digital transformation of manufacturing industry