OpenGLRenderer: Bitmap too large to be uploaded into a texture in android titanium

痴心易碎 提交于 2019-12-08 06:42:40

问题


In Titanium appcelerator, when I capture an image and show in an ImageView, image is not being shown, instead, below warning is being shown.

[WARN] : OpenGLRenderer: Bitmap too large to be uploaded into a texture (1840x3264, max=2048x2048)

How to solve this problem? Whereas in tablet it is working fine, but in high resolution device its not working.

This one occurs when I insert an image into a ImageView when shot from camera or pick from the gallery.


回答1:


This is because different phones have different amounts of texture memory available depending on hardware, and their OpenGL version, this specific value is GL_MAX_TEXTURE_SIZE and can be looked up per phone here and in other places.

To work around this, convert the image to a blob and then resize it using a built-in function: imageAsResized, in the success callback after taking a picture.

Ti.Media.showCamera({
    ....
    success : function(e) {
        // Resized to a size that most phones should support
        var resizedImage = e.media.imageAsResized(1024, 1024);
        // Set the image view with the resized image
        imageView.image = resizedImage;
    },
    ....
});


来源:https://stackoverflow.com/questions/22477508/openglrenderer-bitmap-too-large-to-be-uploaded-into-a-texture-in-android-titani

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!