当前位置:首页 > 笔记

Bitmap too large to be uploaded into a texture

jsc10年前 (2016-04-07)笔记4304
从手机相册里面显示图片,但是发现有的图片能显示有的图片不能显示,路径都是对的,程序也没提示任何错误。
后来通过看日志发现error message: Bitmap too large to be uploaded into a texture (4208x3120, max=4096x4096):
经过查找资料是因为当开启硬件加速的时候,GPU对于openglRender 有一个限制,这个不同的手机会有不同的限制。
简单说就是硬件加速的时候,对图片的大小有限制。不同设备可能有不同的最大值。这个问题悲催的地方是,程序貌似没有捕获到这个exception, 结果是程序也不报错,图片也显示不出来。
 
一个解决的方法是禁止硬件加速 
 <application android:hardwareAccelerated="false" ...>
/**
 * 把uri 转换为 bitmap          注意要关闭硬件加速!!否则会因为图片超大而不显示
 * @param mContext
 * @param mUri
 * @return
 */
public static  Bitmap readBitmapUri(Context mContext,Uri mUri) {
    ContentResolver contentProvider = mContext.getContentResolver();
    Bitmap bmp = null;
    try {
        bmp = BitmapFactory.decodeStream(contentProvider.openInputStream(mUri));
 
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return bmp;
 
}


扫描二维码推送至手机访问。

版权声明:本文由微小站发布,如需转载请注明出处。

本文链接:https://jsc0.com/post/90.html

分享给朋友:

“Bitmap too large to be uploaded into a texture” 的相关文章

java类型

最近在写Java后台, 编译时出现:No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing instance of type E(e.g.  x.new…

百度地图被外部调用的问题

选择手机里安装的外部地图应用,在外部地图应用里显示商户的位置。˂br style="word-wrap: break-word; color: rgb(68, 68, 68); font-family: "Microsoft Yahei&q…

viewpager、listview、gridview、scrollview去除蓝色阴影

xml:   android:overScrollMode="never"java:    view.setOverScrollMode(ScrollView.OVER_SCROLL_NEVER);…

TabLayout getCustomView为空的问题

今天用Tablayout——ViewPage出现getCustomView为空的问题通过源码发现,ViewPage的adapter更新会吧TabLayout  的customViewc置空。这个时候自动调用OnTabSelectedListener的onTabSelected方法去获取Cu…

Notification 8.0 关闭声音震动

NotificationChannel notificationChannel = new NotificationChannel                    (NOTIFICATION_C…