当前位置: 代码迷 >> Android >> 关于Bit地图.createBit地图(Bit地图 source, int x, int y, int width, int height)这个方法
详细解决方案
关于Bit地图.createBit地图(Bit地图 source, int x, int y, int width, int height)这个方法
热度:67 发布时间:2016-04-28 04:05:02.0
关于Bitmap.createBitmap(Bitmap source, int x, int y, int width, int height)这个方法 Bitmap android.graphics.Bitmap.createBitmap(Bitmap source, int x, int y, int width, int height) 这个方法屌爆了,不会用 后面的四个参数到底啥意思啊 不是说截的是一个矩形的x,y,宽高吗/ 为何我传入这个: Bitmap bitmap = Bitmap.createBitmap(b1, 0, 20, b1.getWidth(), b1.getHeight()); 我的意思是从20的高度开始一直到图片的最后
就给我报这个错误 java.lang.IllegalArgumentException: y + height must be <= bitmap.height() 我擦,难道要我填写一个负数么... ------解决思路---------------------- 这个方法很坑爹的。 动不动就内存溢出。。 建议使用 Bitmap dragimg=Bitmap.createScaledBitmap(bmp, lockWidth, lockWidth, true); 方法 输入值分别是 被转换的图片对象 宽和高 最后一个参数是 是否保证等比 ------解决思路----------------------
------解决思路---------------------- java.lang.IllegalArgumentException: y + height must be <= bitmap.height() 是指从一张图片上取某一块,从y点开始到height结束的区域。而你的方法中截取的已经超出图片范围外了。