解决方案 »
- android .9.png图片使用时,有黑边?
- android openGL 3D纹理真机空白
- 求指导!!!在windows7下搭建安卓环境。
- 怎么调用android底层的Java Class?
- 游戏中人物的运动轨迹,高分搜集。。。
- 对于多摄像头的手机,如何实现选择其中某个摄像头的功能
- android 请求webservice 时能够 实现身份验证
- Android下使用Zigbee讨论
- 有源码 和 AndroidManifest.xml, 如何知道编译后, 生成的APK 的名字?
- 大家好,请问在android上怎样实现将两个 视频文件合成一个视频文件 谢谢
- 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.