在cocos2dx 2.2.1截图,安卓手机中看不到图片在哪?
代码如下:
CCSize size = CCDirector::sharedDirector()->getWinSize();
CCRenderTexture* pScreen = CCRenderTexture::create(size.width,size.height, kCCTexture2DPixelFormat_RGBA8888);
CCScene* pCurScene = CCDirector::sharedDirector()->getRunningScene();
pScreen->begin();
pCurScene->visit();
pScreen->end();
pScreen->saveToFile("gameScreen.png", kCCImageFormatPNG);
CC_SAFE_DELETE(pScreen);
安卓中copy出来时,io异常 java.io.FileNotFoundException:
//拷贝截图
public static String CopyGameScreenPic(String picName) throws IOException {
boolean sdExist = Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED);
if (sdExist) {
// 设置图片拷贝后的存储路径
String pathString = Environment.getExternalStorageDirectory()
+ "/mnt/sdcard/";
File f1 = new File(pathString);
if (!f1.exists()) {
f1.mkdirs();
}
String path = pathString + picName;
File share = getContext().getFilesDir().listFiles()[0];
InputStream is = new FileInputStream(share);
FileOutputStream os = new FileOutputStream(path);
byte[] buffer = new byte[1024];
int count = 0;
while ((count = is.read(buffer)) > 0) {
os.write(buffer, 0, count);
}
is.close();
os.close();
return path;
}
return "/mnt/sdcard/";
}
这是什么原因?