我正在使用android.given efects中的OpenGl Es进行图像处理,当我将图像保存在sdcard中时,它显示黑色图像。我解决了这个问题。
文件cacheDir; Toast.makeText(ImageProcessingActivity.this,“Photo”,500).show();
Bitmap icon;
frame.setDrawingCacheEnabled(true);
icon = Bitmap.createBitmap(frame.getDrawingCache());
Bitmap bitmap = icon;
frame.setDrawingCacheEnabled(false);
// File mFile1 = Environment.getExternalStorageDirectory();
Date d = new Date();
String fileName = d.getTime() + "mg1.jpg";
File storagePath = (Environment.getExternalStorageDirectory());
File dest = new File(storagePath + "/CityAppImages");
if (!dest.exists()) {
dest.mkdirs();
}
File mFile2 = new File(dest, fileName);
sdpath = mFile2.getAbsolutePath();
Log.d("qqqqqqqqqqqqqqqqqqqqqqq", "zzzzzzzz" + sdpath);
try {
FileOutputStream outStream;
outStream = new FileOutputStream(mFile2);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
outStream.flush();
outStream.close();
Toast.makeText(ImageProcessingActivity.this, "Photo Saved Sucessfully", 500)
.show();
image.setImageBitmap(bitmap);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Toast.makeText(ImageProcessingActivity.this, "Photo Not Saved Sucessfully",500).show();
}
答案 0 :(得分:0)
我曾经遇到过这个问题,这是因为getDrawingCache不是应该的。问题不在于储蓄,而是你这样做的方式。
根据我的理解,您希望捕获应用程序的屏幕,但这非常棘手,可能会导致很多问题。
阅读本主题,因为当我遇到这个问题时,它对我帮助很大。 How to programmatically take a screenshot in Android?
编辑: 此外,因为您正在使用GLES然后打印屏幕,您应该转到设置>开发人员选项>选中“禁用硬件覆盖并强制GPU渲染”。