当前位置:网站首页>【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。边栏推荐
- PAT 乙等 1011 C语言
- What benefits have digital collections enabled the real industry to release?
- 技能自检 | 想当测试Leader,这6项技能你会吗?
- Centos7 deploy radius service -freeradius-3.0.13-15 EL7 integrating MySQL
- Genetic engineering of AI art? Use # artbreeder to change any shape of the image
- How can digital collections empower economic entities?
- Software design and Development Notes 2: serial port debugging tool based on QT design
- 【owt】owt-client-native-p2p-e2e-test vs2017构建 6:修改脚本自动生成vs工程
- Wireshark TS | 视频 APP 无法播放问题
- True MySQL interview question (21) - Finance - overdue loan
猜你喜欢

jvm-06. Garbage collector

Deploy docker and install MySQL in centos7

Activity启动模式和生命周期实测结果

True MySQL interview question (21) - Finance - overdue loan

Data migration from dolphin scheduler 1.2.1 to dolphin scheduler 2.0.5 and data test records after migration

jvm-01.指令重排

True MySQL interview question (24) -- row column exchange

MySQL面试真题(二十七)——RFM分析法对用户进行分类

编址和编址单位

Digital collections - new investment opportunities
随机推荐
制造业数字化转型存在问题及原因分析
PAT 乙等 1009 C语言
Leetcode topic analysis add binary
Real MySQL interview questions (25) -- common group comparison scenarios
线性表 链表结构的实现
Explicability of counter attack based on optimal transmission theory
Android handler memory leak kotlin memory leak handling
June 22, 2022: golang multiple choice question, what does the following golang code output? A:3; B:1; C:4; D: Compilation failed. package main import ( “fmt“ ) func mai
Leetcode topic analysis: factorial training zeroes
Redis cache penetration solution - bloom filter
关于安装pip3 install chatterbot报错的问题
使用链表实现两个多项式相加和相乘
Basic calculator II for leetcode topic analysis
True question of MySQL interview (29) -- case - finding favorite movies
Wireshark TS | 视频 APP 无法播放问题
PAT 乙等 1024 科学记数法 C语言
PAT 乙等 1019 C语言
数字藏品赋能实体产业释放了哪些利好?
PAT 乙等 1022 D进制的A+B
The traditional Internet like platform may no longer exist, and a new industry integrating industrial characteristics and Internet characteristics