美文网首页
图片最大纹理高度

图片最大纹理高度

作者: Jayden_ | 来源:发表于2017-06-21 15:55 被阅读0次

    每个手机能显示的最大图片高度是有限的,超过则无法正常显示。

        /**
         * 获取图片最大纹理高度
         *
         * @return
         */
        public int getMaximumTextureSize() {
            EGL10 egl = (EGL10) EGLContext.getEGL();
            EGLDisplay display = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
    
            // Initialise
            int[] version = new int[2];
            egl.eglInitialize(display, version);
    
            // Query total number of configurations
            int[] totalConfigurations = new int[1];
            egl.eglGetConfigs(display, null, 0, totalConfigurations);
    
            // Query actual list configurations
            EGLConfig[] configurationsList = new EGLConfig[totalConfigurations[0]];
            egl.eglGetConfigs(display, configurationsList, totalConfigurations[0], totalConfigurations);
    
            int[] textureSize = new int[1];
            int maximumTextureSize = 0;
    
            // Iterate through all the configurations to located the maximum texture size
            for (int i = 0; i < totalConfigurations[0]; i++) {
                // Only need to check for width since opengl textures are always squared
                egl.eglGetConfigAttrib(display, configurationsList[i], EGL10.EGL_MAX_PBUFFER_WIDTH, textureSize);
    
                // Keep track of the maximum texture size
                if (maximumTextureSize < textureSize[0]) {
                    maximumTextureSize = textureSize[0];
                }
    
                Logger.i("GLHelper", Integer.toString(textureSize[0]));
            }
    
            // Release
            egl.eglTerminate(display);
            Logger.i("GLHelper", "Maximum GL texture size: " + Integer.toString(maximumTextureSize));
    
            return maximumTextureSize;
    
        }
    

    相关文章

      网友评论

          本文标题:图片最大纹理高度

          本文链接:https://www.haomeiwen.com/subject/skktcxtx.html