【问题标题】:OpenGLRenderer: Bitmap too large to be uploaded into a texture in android titaniumOpenGLRenderer:位图太大而无法上传到android钛中的纹理
【发布时间】:2014-03-18 11:07:16
【问题描述】:
在 Titanium appcelerator 中,当我捕获图像并在 ImageView 中显示时,没有显示图像,而是显示以下警告。
[警告]:OpenGLRenderer:位图太大,无法上传到纹理中(1840x3264,max=2048x2048)
如何解决这个问题?
而在平板电脑中它可以正常工作,但在高分辨率设备中它无法正常工作。
当我从相机拍摄或从图库中挑选图像时将图像插入ImageView 时会发生这种情况。
【问题讨论】:
标签:
android
camera
titanium
appcelerator-mobile
【解决方案1】:
这是因为不同的手机有不同数量的纹理内存可用,具体取决于硬件和它们的 OpenGL 版本,这个特定的值是 GL_MAX_TEXTURE_SIZE 并且可以在每个手机 here 和其他地方查找。
要解决此问题,请将图像转换为 blob,然后使用内置函数调整其大小:imageAsResized,在拍照后的成功回调中。
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;
},
....
});