1
私のアプリのスクリーンショットを保存しようとしています。 メイン画面はSurfaceViewです。私は新しいキャンバスを作成し、キャンバスにサーフェイスビューを描画しています。私は問題があります。なぜなら、私が得るPNGは完全に透明であるからです。ここでキャンバスにサーフェイスビューを保存
は私のコード
Bitmap image = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(image);
draw(c);
String path=Environment.getExternalStorageDirectory() + "/test2.png";
File file = new File(path);
try
{
file.createNewFile();
FileOutputStream ostream = new FileOutputStream(file);
image.compress(CompressFormat.PNG, 100, ostream);
ostream.close();
Uri screenshotUri = Uri.parse("file://"+file.getAbsolutePath());
Intent sendIntent = new Intent(Intent.ACTION_VIEW);
sendIntent.setDataAndType(screenshotUri, "image/png");
startActivity(sendIntent);
}
catch (Exception e)
{
e.printStackTrace();
}
スナップショットを撮ろうとすると、My Surfaceが作成されます(画面にゲームが表示されます)。 – Alex