无法显示在Android上的图像格式PNG [英] Can't display image formatted png on Android

查看:142
本文介绍了无法显示在Android上的图像格式PNG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我遇到一个奇怪的问题。我有一个png图片image.png,这是由Java的code generatied和anthor形象a.png。我导入到 / SD卡/图像/ 目录。当我调用code

Today I encounter a strange question. I have a png image "image.png", which is generatied by Java code, and anthor image "a.png". I import them to /sdcard/image/ directory. When I invoke code

Bitmap bit = BitmapFactory.decodeFile("/sdcard/image/image.png");

bit = BitmapFactory.decodeFile("/sdcard/image/a.png");

在Android上,第一位是零,但后者不是。我相信路径/ SD卡/图像是正确的。

on Android, the first bit is null but the latter is not. I am sure the path "/sdcard/image" is right.

你能帮我吗?

推荐答案

您可以从这个code得到SD卡的路径:

You can get the path of sdcard from this code:

File extStore = Environment.getExternalStorageDirectory();

然后指定文件夹名和文件名

Then specify the foldername and file name

"/image/"+"image.jpg"


bit = BitmapFactory.decodeFile(extStore +"/image/a.jpg");

这篇关于无法显示在Android上的图像格式PNG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆