jjzjj

decodeStream

全部标签

java - 当某些字节错误时,BitmapFactory.decodeStream(inputStream) 总是返回 null

我正在构建一个Android应用程序,但我目前无法从URL检索位图。这是我正在使用的代码:publicstaticBitmapbmpFromURL(URLimageURL){Bitmapresult=null;try{HttpURLConnectionconnection=(HttpURLConnection)imageURL.openConnection();connection.setDoInput(true);connection.connect();InputStreaminput=connection.getInputStream();result=BitmapFactory

android - BitmapFactory.decodeStream 总是返回 null 并且 skia 解码器显示解码返回 false

测试图片在这里:http://images.plurk.com/tn_4134189_bf54fe8e270ce41240d534b5133884ee.gif我已经尝试了在Internet上找到的几种解决方案,但没有有效的解决方案。我正在使用以下代码fragment:UrlimageUrl=newUrl("http://images.plurk.com/tn_4134189_bf54fe8e270ce41240d534b5133884ee.gif");Bitmapimage=BitmapFactory.decodeStream(imageUrl.openStream());总是得到这个

android - decodeStream 返回 null

我正在尝试领养bitmapresizing教程-唯一的区别是我使用decodeStream而不是decodeResource。这很奇怪,但是没有任何操作的decodeStream给了我一个位图obj,但是当我通过decodeSampledBitmapFromStream时,它出于某种原因返回null。我该如何解决?这是我使用的代码:protectedHandler_onPromoBlocksLoad=newHandler(){@OverridepublicvoiddispatchMessage(Messagemsg){PromoBlocksContainerc=(PromoBlocks

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 - 位图 decodeStream OutOfMemory 异常

我在我的应用程序中使用我自己的AndroidViewFlow示例实现。我正在从网络服务下载加密图像,而不是将它们保存在SD卡上。我正在使用viewflow即时解密图像并显示它们。但问题是,当用户开始过快地更改图像时,它会向我抛出OutOfMemoryException并且我发现/测试的所有信息都不适用于我的情况。这是我正在使用的:@OverridepublicViewgetView(intposition,ViewconvertView,ViewGroupparent){if(convertView==null){convertView=mInflater.inflate(R.layo

安卓:bitmapfactory.decodestream 返回 null

我试图从图像的路径中获取位图图像。但是BitmapFactory.decodeStream返回null值。代码:URLurl=newURL(path);HttpURLConnectionconnection=(HttpURLConnection)url.openConnection();connection.setDoInput(true);connection.connect();InputStreaminput=connection.getInputStream();BitmapmyBitmap=BitmapFactory.decodeStream(input);connectio

android - BitmapFactory.decodeStream 无一异常(exception)地返回 null

我尝试从服务器加载远程图像,感谢stackoverflow上的大量代码示例,我有一个解决方案可以在3个图像中的2个中工作。我真的不知道第三张图片有什么问题,有时当让代码在调试器中运行时图片正在加载。另外,如果我先加载问题图片,有时其他两张图片不会加载。代码如下:publicstaticDrawablegetPictureFromURL(Contextctx,Stringurl,finalintREQUIRED_SIZE)throwsNullPointerException{//DecodeimagesizeBitmapFactory.Optionso=newBitmapFactory.

android - BitmapFactory.decodeStream 内存不足,尽管使用了减少的样本大小

我看了很多关于解码位图的内存分配问题的相关帖子,但使用官网提供的代码仍然无法找到以下问题的解决方案。这是我的代码:publicstaticBitmapdecodeSampledBitmapFromResource(InputStreaminputStream,intreqWidth,intreqHeight){ByteArrayOutputStreambaos=newByteArrayOutputStream();byte[]buffer=newbyte[1024];intlen;try{while((len=inputStream.read(buffer))>-1){baos.wri

c# - BitmapFactory.DecodeStream 上的 Android 单声道退出代码 255

我正在使用MonoforAndroid(本文发布时的最新版本)和VisualStudio插件来构建Android应用程序。它以API级别8、Android2.2框架为目标。该应用程序在运行Android版本2.2.2的摩托罗拉Droid上运行良好它在运行Android2.3.3的摩托罗拉DroidX2上崩溃,调试器几乎没有输出唯一的输出是:“Mono”程序已退出,代码为255(0xff)。崩溃发生在以using(Bitmap...开头的行的此方法中publicstaticDrawableGetDrawable(stringurl){try{HttpWebRequestrequest=(

android - BitmapFactory.decodeStream(InputStream is) 在 Android 上为非 null InputStream 返回 null

我正在开发一个Android应用程序,它的View包含多个图库。图库的内容(位图)是来自Internet的红色。对于第一个画廊,一切正常,但是当尝试下载第二个画廊的第一张图片时,BitmapFactory.decodeStream(InputStream)返回null,而流不为null。publicvoidloadBitmap()throwsIOException{for(inti=0;igetThumbUrl()返回图像的URL(例如http://mydomain.com/image.jpg)并在Log.i("MY_TAG","Height:...)行抛出一个NullPointerE
12