我的代码不是从路径创建位图,我已经搜索了很多次,但没有找到解决方案,这是我的代码
val bitmap=BitmapFactory.decodeFile(path)它总是返回null,我也尝试过glide这样做,但都没有效果
Glide.with(requireActivity()).asBitmap().load(pictureFilePath)
.apply(RequestOptions().override(50, 50))
.listener(object : RequestListener<Bitmap> {
override fun onLoadFailed(e: GlideException?, model: Any?, target: com.bumptech.glide.request.target.Target<Bitmap>?, isFirstResource: Boolean): Boolean {
return false
}
override fun onResourceReady(bitmap: Bitmap, model: Any?, target: com.bumptech.glide.request.target.Target<Bitmap>?, dataSource: DataSource?, isFirstResource: Boolean): Boolean {
val mybitmap= bitmap // this bitmap return null
return true
}
}).submit()有人能帮我解决这个小问题吗?我已经厌倦了这样做
发布于 2020-06-14 23:52:11
使用此选项,path是您的本地路径请确保您的路径是正确的
BitmapFactory.Options bmOptions = new BitmapFactory.Options();
Bitmap bitmap = BitmapFactory.decodeFile(path.getAbsolutePath(),bmOptions);
bitmap = Bitmap.createScaledBitmap(bitmap,parent.getWidth(),parent.getHeight(),true);https://stackoverflow.com/questions/62374628
复制相似问题