如果检测分辨率是Android上的棒棒糖过高 [英] Detect if resolution is too high on Android Lollipop

查看:140
本文介绍了如果检测分辨率是Android上的棒棒糖过高的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要显示在ImageView的一些照片。
他们中有些人可能有一个分辨率太高,让我

I have to display some pictures in an ImageView. Some of them may have a resolution too high that gives me

W/OpenGLRenderer﹕ Bitmap too large to be uploaded into a texture (3744x5616, max=4096x4096)

我用这个方法来检测这种情况:

I used this method to detect this situation:

public boolean isResTooHigh() {
    int[] maxSize = new int[1];
    GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxSize, 0);

    return (maxSize[0] < width) || (maxSize[0] < height);
}

,其中由图片的源被提供的宽度和高度。

where width and height are provided by the source of the pictures.

但现在我的Nexus 4运行棒棒糖和我的模拟器,MAXSIZE [0]始终为0。
所以,我怎么发现这个问题?

But now on my Nexus 4 running Lollipop and my emulators, maxSize[0] is always 0. So, how do I detect this problem?

推荐答案

这GL查询需要的线程上活跃GL上下文。 previously您的应用程序不小心使用框架的私人GL上下文来执行查询。在棒棒堂因各种建筑改变了这种情况下不再泄漏到应用code,因此为什么查询但现在失败。如果你在看logcat中你可能会看到:打电话的OpenGL ES API没有当前上下文

That GL query requires an active GL context on the thread. Previously your app was accidentally using framework's private GL context to perform that query. In Lollipop due to various architecture changes this context no longer leaks into application code, hence why the query is now failing. If you look in logcat you will probably see something like: "call to opengl es api with no current context".

您可以创建自己的GL上下文如果要执行查询。或者你可以假设屏幕的分辨率为最大,或者使用一个可扩展的解决方案,如瓷砖的方法。

You can create your own GL context to perform that query if you want. Alternatively you can assume the screen resolution is the maximum, or use a scalable solution such as a tiled approach.

这篇关于如果检测分辨率是Android上的棒棒糖过高的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆