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.