从 png.class 读取时出错
当我尝试使用以下代码从 URL 加载图像时(已删除真实图像路径):
Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL("http://some-path/img.png").getContent());
我收到以下错误:
Error reading from ./org/apache/harmony/awt/www/content/image/png.class
对于可能导致错误的原因有什么想法吗?
我正在使用 GoogleTV AVD,如果这很重要的话。
When I attempt to load an image from a URL, using the following code (real image path removed):
Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL("http://some-path/img.png").getContent());
I receive the following error:
Error reading from ./org/apache/harmony/awt/www/content/image/png.class
Any thoughts on what might be causing the error?
I am using a GoogleTV AVD, if that matters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我希望这已经足够了。
如果您使用的是 php;
在 android 上:
这可能不是最有效的方法,但它应该可以完成工作。
从那里你可以构建:)
之后你可以将位图压缩成PNG,并保护它。例如:
convertStreamToString 是很容易找到的方法。只需快速进行谷歌搜索,或者编写您自己的。
I hope this will be sufficient.
If you are using php;
on android:
This is probably not the most efficient way, but it should do the job.
From there on you can build :)
You can compress the bitmap into a PNG after, and safe it. example:
convertStreamToString are easily found methods. Just do a quick google search, or write your own.
尝试这个方法:它对我有用这返回位图
写这个方法
Try this method: its working for me This returns bitmap
write this method
据我经历过像你这样的场景,我发现图像的输入流无法通过获取流的简单方法来获取,请尝试更新代码中的以下内容,然后检查结果。我相信你会得到你想要的。
这是可以在类中声明的方法,以便在解码流方法中直接调用
As far as i have experienced the scenario like yours i found that the input stream for an image cannot be obtained by simple methods of getting stream try to update the following things in your code and then check results. I'm sure you will get what you want.
and here is the method which can be declared within class to be called directly in your decode stream method
我的猜测是
My guess would be