草庐IT

decodefile

全部标签

java - 从文件路径设置 ImageView 的图像。 BitmapFactory.decodeFile、BitmapFactory.decodeStream 还是 Drawable.fromFile?

哪种设置ImageView图像的方法更好(使用更少的堆空间)?imageView.setImageDrawable(Drawable.createFromPath(path));或imageView.setImageBitmap(BitmapFactory.decodeFile(path));或is=newFileInputStream(path);imageView.setImageBitmap(BitmapFactory.decodeStream(is));is.close();BitmapFactory会让我设置一个inSampleSize,所以我不会拉太大的位图。Drawabl

android - BitmapFactory.decodeFile 返回 fileNotFoundException

我有一个关于BitMapFactory.decodeFile的问题。在我的应用中,我希望用户能够从他/她的设备中选择图像或拍照。然后必须将其显示在ImageView(medication_photo)中。我也尝试缩小图像,因为在我之前的代码中我遇到了OutOfMemory错误。问题是在选择图片后,我的应用抛出了这个异常:FileNotFoundException:Unabletodecodestream:java.io.FileNotFoundException:/content:/media/external/images/media/1499:openfailed:ENOENT(N

android - BitmapFactory.decodeFile();

在我的应用程序中,我有一个文件:privateFileTEMP_PHOTO_FILE=newFile(Environment.getExternalStorageDirectory(),"temp_photo.jpg");这是直接在我的类中声明的,并且对其中的所有方法都是可见的。我想用这个:BitmapthePhoto=BitmapFactory.decodeFile(Uri.fromFile(TEMP_PHOTO_FILE).toString());Uri.fromFile(TEMP_PHOTO_FILE).toString()生成字符串:“file:///mnt/sdcard/te

android - Android 中的 FileProvider 路径创建和 BitmapFactory.decodefile 问题

我正在尝试使用BitmapFactory.decodefile()来创建按比例缩小的文件相机照片的版本并将其设置为我的框架布局中的ImageView。我正在按照Android开发人员的以下说明进行操作:https://developer.android.com/training/camera/photobasics.html在这些说明中,文件被创建并存储在一个文件提供程序中,该文件提供程序包含一些以xml格式设置的元数据文件。不知何故,BitmapFactory.decodefile()似乎无法访问此文件,该文件存储其内容uri驻留在文件提供程序中的图片。fileprovider是在a

android - BitmapFactory.decodeFile() 中的 OutOfMemoryError

当我从图库中选取图像时,如果图像大小大于3Mb,android会出现OutOfMemoryError。BitmapFactory.Optionsoptions=newBitmapFactory.Options();options.inPreferredConfig=Bitmap.Config.ARGB_8888;Bitmapbmp=BitmapFactory.decodeFile(imageFilePath,options);此文本来自日志。请帮助我,因为“最后期限”)E/AndroidRuntime﹕FATALEXCEPTION:mainjava.lang.OutOfMemoryEr

Android BitmapFactory.decodeFile 间歇性地返回 null

我正在使用android4.0.4,内核3.0.8+BitmapFactory.decodeFile每隔一段时间就会返回一个空位图。请注意,如果位图工厂加载位图失败,我会立即重试,最多4次,这通常有效(!)有很多人提示这个。大多数问题的答案都涉及位图的放置位置,或者刷新输入流的性质/http连接/等等。我已经排除了这些可能性-事实上,我已经将我的问题简化为一个android应用程序,它非常简单,可以称为测试用例。我的应用程序只有一个Activity,其中包含一个按钮,按下该按钮会启动一个线程,该线程循环遍历外部文件目录,试图将其中的所有内容加载到位图中。我不使用位图,也不保留它或其他任

在Android中,bitmapfactory.decodefile不起作用

我使用以下代码在SD卡中获取图像,然后通过ImageView显示图像:Bitmapbmp=BitmapFactory.decodeFile(imgUri.getPath());img.setImageBitmap(bmp);但是,什么都没有显示。我以这种方式编辑了AndroidManifest.xml:但这不起作用。现在,我知道SD卡中的图像没有由程序读取。我该如何解决问题?PS:我使用的手机是Redmi4X,操作系统是MIUI8。看答案因为file://或者content://使它不正确。尝试这个:Uriuri;Contextcontext;try{Bitmapbmp=BitmapFacto

Android:decodeFile 总是为内部存储中的文件返回 null

我有一个文件本地保存到应用程序的私有(private)存储中。我已经验证它存在,但是每当我调用BitmapFactory.decodeFile它总是返回null.如果我将文件保存为资源并使用ImageView.setImageResource,它总是显示得很好。有什么问题?这是fragment:filename="test.png";if(doesFileExist(filename))BitmapbMap=BitmapFactory.decodeFile(filename);我也试过了:BitmapbMap=BitmapFactory.decodeFile(getFilesDir()

Android:decodeFile 总是为内部存储中的文件返回 null

我有一个文件本地保存到应用程序的私有(private)存储中。我已经验证它存在,但是每当我调用BitmapFactory.decodeFile它总是返回null.如果我将文件保存为资源并使用ImageView.setImageResource,它总是显示得很好。有什么问题?这是fragment:filename="test.png";if(doesFileExist(filename))BitmapbMap=BitmapFactory.decodeFile(filename);我也试过了:BitmapbMap=BitmapFactory.decodeFile(getFilesDir()

android - BitmapFactory.decodeFile 返回 null

我将使用Bitmap.compress()方法压缩图像。但是当我使用bitmap=BitmapFactory.decodeFile()获取Bitmap时,我得到了一个null对象,并且该方法没有显示任何异常(exception)。这是我的代码publicstaticFilecompressImage(StringimagePath)throwsIOException{//GetbitmapBitmapFactory.Optionsoptions=newBitmapFactory.Options();options.inJustDecodeBounds=true;Bitmapbitmap
12