我对OpenGL知之甚少,所以请温柔一点。
应用程序需要加载位图(从资源中),调整它的大小,并在 OpenGL 纹理中使用它。我有一个可行的实现,但是 Wildfire S 上存在一个糟糕的条带问题。所以我更改了实现并修复了条带问题(通过切换到 ARGB_8888),但这破坏了 Galaxy Nexus 和 Nexus One 上的功能。
我看到三个视觉演示:
位图(平滑的 24 位渐变)显示正确,没有条纹。
渐变显示,但有明显的条带
纹理显示为纯白色,没有位图(或 logcat 中的问题)
以下是加载位图的方法的两个版本,并说明了每个版本的结果:
// White on Galaxy Nexus. White on Nexus One. Renders correct image (no banding) on Wildfire S
private Bitmap getBitmap1() {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
options.outWidth = getTextureSize();
options.outHeight = getTextureSize();
final Bitmap bmp;
bmp = BitmapFactory.decodeResource(getResources(), bitmapResourceId, options);
return bmp;
}
// Renders correctly (no banding) on Galaxy Nexus. Renders on Nexus One and Wildfire S but with obvious banding.
private Bitmap getBitmap2() {
int textureSize = getTextureSize();
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
options.outWidth = getTextureSize();
options.outHeight = getTextureSize();
final Bitmap bmp;
bmp = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), bitmapResourceId, options), textureSize, textureSize, true);
return bmp;
}
getTextureSize() 返回 1024。
如何构建一种方法来显示位图而不在所有设备上进行条带化,并且没有任何设备显示大白框?