Bitmap too large to be uploaded into a texture
来源:互联网 发布:mac pro 常用软件 编辑:程序博客网 时间:2024/05/16 06:54
android应用载入图片太大的时候,在API 11以上会出现这个错误,因为开启硬件加速的时候,系统对载入图片的大小有限制,可以通过如下方法解决:
- 关闭硬件加速:
android:hardwareAccelerated="false"
- 将载入的图片进行优化,只取出需要的大小:
public static Bitmap decodeSampledBitmapFromPath(String path, int reqWidth, int reqHeight) { // First decode with inJustDecodeBounds=true to check dimensions final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(path, options); // Calculate inSampleSize options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight); // Decode bitmap with inSampleSize set options.inJustDecodeBounds = false; return BitmapFactory.decodeFile(path, options);}public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId, int reqWidth, int reqHeight) { // First decode with inJustDecodeBounds=true to check dimensions final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeResource(res, resId, options); // Calculate inSampleSize options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight); // Decode bitmap with inSampleSize set options.inJustDecodeBounds = false; return BitmapFactory.decodeResource(res, resId, options);}public static int calculateInSampleSize(BitmapFactory.Options options,int reqWidth, int reqHeight) {// Raw height and width of imagefinal int height = options.outHeight;final int width = options.outWidth;int inSampleSize = 1;if (height > reqHeight || width > reqWidth) {final int halfHeight = height / 2;final int halfWidth = width / 2;// Calculate the largest inSampleSize value that is a power of 2 and// keeps both// height and width larger than the requested height and width.while ((halfHeight / inSampleSize) > reqHeight&& (halfWidth / inSampleSize) > reqWidth) {inSampleSize *= 2;}}return inSampleSize;}
0 0
- Bitmap too large to be uploaded into a texture
- Bitmap too large to be uploaded into a texture 解决方法
- Bitmap too large to be uploaded into a texture exception
- Bitmap too large to be uploaded into a texture
- Bitmap too large to be uploaded into a texture
- Bitmap too large to be uploaded into a texture
- Bitmap too large to be uploaded into a texture
- Bitmap too large to be uploaded into a texture 解决方案
- Bitmap too large to be uploaded into a texture 解决方法
- Bitmap too large to be uploaded into a texture
- 解决:Bitmap too large to be uploaded into a texture exception
- 解决:Bitmap too large to be uploaded into a texture exception
- 关于使用ImageLoader出现的Bitmap too large to be uploaded into a texture
- 解决:Bitmap too large to be uploaded into a texture exception
- 解决:Bitmap too large to be uploaded into a texture exception
- Bitmap too large to be uploaded into a texture问题的解决方法
- Bitmap too large to be uploaded into a texture,Hardware accelerated
- 解决:Bitmap too large to be uploaded into a texture exception
- hdoj.2050 折线分割平面 20141108
- memcached 在 centos 的安装测试
- 程矢Axure夜话:中继器系列视频教程之中继器表格添加数据
- JFreeChart在Struts2中实现3D柱状图统计
- android ListView嵌套的处理方法
- Bitmap too large to be uploaded into a texture
- 程矢Axure夜话:中继器系列视频教程之中继器表格搜索
- 《unix高级环境编程》进程关系——会话
- js中的触屏事件
- 程矢Axure夜话:中继器系列视频教程之中继器表格生成连续序号
- insert /*+ APPEND */
- TinyOs博客资源汇总
- 程矢Axure夜话:中继器系列视频教程之中继器表格设置特定单元格样式
- Android 4.0 Launcher2源码分析——主布局文件