解决方案 »
- 解析错误 解析包时出现问题
- BroadcastReceiver 启动 Activity 无法全屏
- 双音频混合
- webview中 input type为 file 的问题,在线等
- 请问这个界面是怎样实现?或者有什么替代实现的
- 纠结中.....
- 求日历编写思路?
- 用setContentView(new MyView(this))设置显示自定义的view视图导致程序异常终止
- 谁有关于讲解搭建与客户端通信的服务器的视频
- 请问如何 设置 listview和 ItemLongClickListener 触发 时间
- Android UI设计:一个文本框位置的设置
- View2.setBackgroundResource 后 View1.setLeft 的位置无效的问题
Bitmap
canvas.drawBitmap(source, srcR, dstR, paint);
Bitmap newBm = Bitmap.createScaledBitmap(bm , 100,100, true);
我回收的是bm 为何newBm也变成recyled了, 这两个bitmap不是同一个对象啊
也就是说: Bitmap newBm = Bitmap.createScaledBitmap(bm , 100,100, true); 我把bm回收 为什么newBm也跟着回收了?
If the specified width and height are the same as the current width and height of the source btimap, the source bitmap is returned and now new bitmap is created.
你上面的做法是把Bm当做参数传进去,然后,你又回收了这个Bm参数,所以系统给你报了非法参数的异常。
Bitmap bm = BitmapFactory.decodeResource(res, id);
Bitmap newBm = Bitmap.createScaledBitmap(bm , 100,100, true);
bm.recyle();
mImageView.setImageBitmap(null);//使用之前一定要先把ImageView清空,要不然会出现你所述的异常
mImageView.setImageBitmap(newBm);
你需要检查newBmp和bm是不是同一个图片。
The new scaled bitmap or the source bitmap if no scaling is required.
楼主检查一下创建的和原图片的宽高是否一样,如果一样返回的就是原本的bitmap,不创建新的,bm和newBm引用的是一个bitmap.