Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 检索“;“干净”;图像视图外的图像_Android_Bitmap_Imageview - Fatal编程技术网

Android 检索“;“干净”;图像视图外的图像

Android 检索“;“干净”;图像视图外的图像,android,bitmap,imageview,Android,Bitmap,Imageview,我已经将图像存储在ImageView中,经过几个过程(翻转、旋转、固定颜色等)后,它会保存回新文件。然而,我才意识到,当我只是加载到ImageView中,然后直接保存结果时,我得到了不同的结果。请看附件中的图片以供参考 图像源 图像结果 以下是我如何从ImageView中提取图像: String filePath = Environment.getExternalStorageDirectory() + File.separator + bufferPath; ByteArrayOutput

我已经将图像存储在ImageView中,经过几个过程(翻转、旋转、固定颜色等)后,它会保存回新文件。然而,我才意识到,当我只是加载到ImageView中,然后直接保存结果时,我得到了不同的结果。请看附件中的图片以供参考

图像源

图像结果

以下是我如何从ImageView中提取图像:

String filePath = Environment.getExternalStorageDirectory()
+ File.separator + bufferPath;
ByteArrayOutputStream bytes = new ByteArrayOutputStream();

selectedImage.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(selectedImage.getDrawingCache());
selectedImage.setDrawingCacheEnabled(false);

bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes);

imageFile = new File( filePath );

//write the bytes in file
FileOutputStream fo = new FileOutputStream(imageFile);
fo.write(bytes.toByteArray());

是否有任何解决方法使生成的图像与源图像相同?可能是不同的组件?

持有一个备份
位图(最初是源代码),您可以对其执行操作


使用
ImageView
仅显示
位图
-不要操作
ImageView
的绘图缓存中保存的后缩放版本。

哈哈哈,你说得对,我应该只使用ImageView作为显示。