开发者

Create Bitmap from byte array using OpenGL in Android

I have a ByteArray and want to create a bitmap out of it using OpenGL. In Android, there is decodeByteArray() method which returns a Bitmap object that can be drawn on ImageVi开发者_如何学Pythonew.

What is the equivalent method available in OpenGL?


There is no equivalent function in OpenGL (ES) since it is a pure API and not made for decoding byte arrays. However, if you want to apply some texture onto your model you might use an approach like this:

gl.glGenTextures(1, textures, 0);
gl.glBindTexture(GL10.GL_TEXTURE_2D, textures[0]);

gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER,GL10.GL_NEAREST);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER,GL10.GL_LINEAR);

gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S,GL10.GL_REPEAT);
gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T,GL10.GL_REPEAT);

GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, texture, 0);

texture.recycle();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜