“位图太大无法上传到纹理中" [英] "Bitmap too large to be uploaded into a texture"

查看:23
本文介绍了“位图太大无法上传到纹理中"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将位图加载到 ImageView 中,并看到此错误.我认为此限制与 OpenGL 硬件纹理 (2048x2048) 的大小限制有关.我需要加载的图片是大约 4,000 像素高的双指缩放图片.

I'm loading a bitmap into an ImageView, and seeing this error. I gather this limit relates to a size limit for OpenGL hardware textures (2048x2048). The image I need to load is a pinch-zoom image of about 4,000 pixels high.

我试过在清单中关闭硬件加速,但没有任何乐趣.

I've tried turning off hardware acceleration in the manifest, but no joy.

    <application
        android:hardwareAccelerated="false"
        ....
        >

是否可以将大于 2048 像素的图像加载到 ImageView 中?

Is it possible to load an image larger than 2048 pixels into an ImageView?

推荐答案

所有渲染都是基于 OpenGL,所以你不能超过这个限制(GL_MAX_TEXTURE_SIZE 取决于设备,但是最小值为 2048x2048,因此任何低于 2048x2048 的图像都适合).

All rendering is based on OpenGL, so no you can't go over this limit (GL_MAX_TEXTURE_SIZE depends on the device, but the minimum is 2048x2048, so any image lower than 2048x2048 will fit).

对于如此大的图像,如果您想放大并且在手机中,您应该设置一个类似于您在谷歌地图中看到的系统.将图像分成几部分,并进行多种定义.

With such big images, if you want to zoom in out, and in a mobile, you should setup a system similar to what you see in google maps for example. With the image split in several pieces, and several definitions.

或者您可以在显示之前缩小图像(参见 user1352407 对这个问题的回答).

Or you could scale down the image before displaying it (see user1352407's answer on this question).

此外,请注意将图像放入哪个文件夹,Android 可以自动放大图像.看看 Pilot_51 的回答下面就这个问题.

And also, be careful to which folder you put the image into, Android can automatically scale up images. Have a look at Pilot_51's answer below on this question.

这篇关于“位图太大无法上传到纹理中"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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