1

I have a CCScene in one my CCLayer class, i need to take screen shot of it and save as Image file. Please help me to get it.

    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();

}

This code didnt worked out. Returns 0kb image file. I need it in java.

Neela
  • 1,328
  • 4
  • 23
  • 45

1 Answers1

0

If CCRenderTexture is available in the Android port I suggest using that. I have an example here, even though it's for iPhone it should generally show the basic use of CCRenderTexture.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217