2011-12-02 3 views
1

내 CCLayer 클래스에 CCScene이 있는데, 그 스크린 샷을 찍어 이미지 파일로 저장해야합니다. 그것을 얻도록 도와주세요.안드로이드 cocos2d CCscene의 스크린 샷을 찍는 방법?

View myView = findViewById(R.id.form); 
Bitmap bmp = Bitmap.createBitmap(myView.getMeasuredWidth() , myView.getMeasuredHeight() , Config.ARGB_8888); 
Canvas canvas = new Canvas(bmp); 
myView.draw(canvas); 
try { 
FileOutputStream out = new FileOutputStream("/sdcard/screen.jpg"); 
bmp.compress(Bitmap.CompressFormat.JPEG, 100, out); 
out.flush(); 
out.close(); 
} catch (Exception e) { 

e.printStackTrace(); 

} 

이 코드는 효과가 없습니다. 0kb 이미지 파일을 반환합니다. 자바에서 필요합니다.

답변

0

CCRenderTexture가 Android 포트에서 사용 가능한 경우 사용하는 것이 좋습니다. 내가 example here을 가지고 있는데, iPhone 용이므로 일반적으로 CCRenderTexture의 기본 사용법을 보여 주어야합니다.

+0

답장을 보내 주셔서 감사합니다. – Neela

관련 문제