本文整理汇总了Java中android.opengl.ETC1Util.compressTexture方法的典型用法代码示例。如果您正苦于以下问题:Java ETC1Util.compressTexture方法的具体用法?Java ETC1Util.compressTexture怎么用?Java ETC1Util.compressTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.opengl.ETC1Util
的用法示例。
在下文中一共展示了ETC1Util.compressTexture方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import android.opengl.ETC1Util; //导入方法依赖的package包/类
public void load(GL10 gl) {
int width = 128;
int height = 128;
Buffer image = createImage(width, height);
ETC1Util.ETC1Texture etc1Texture = ETC1Util.compressTexture(image, width, height, 3, 3 * width);
if (USE_STREAM_IO) {
// Test the ETC1Util APIs for reading and writing compressed textures to I/O streams.
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ETC1Util.writeTexture(etc1Texture, bos);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
ETC1Util.loadTexture(GLES10.GL_TEXTURE_2D, 0, 0,
GLES10.GL_RGB, GLES10.GL_UNSIGNED_SHORT_5_6_5, bis);
} catch (IOException e) {
Log.w(TAG, "Could not load texture: " + e);
}
} else {
ETC1Util.loadTexture(GLES10.GL_TEXTURE_2D, 0, 0,
GLES10.GL_RGB, GLES10.GL_UNSIGNED_SHORT_5_6_5, etc1Texture);
}
}
示例2: makeImage
import android.opengl.ETC1Util; //导入方法依赖的package包/类
private void makeImage(Render render, float angle, String name) throws IOException {
Bitmap bitmap = render.getImage(angle);
int dim = bitmap.getHeight();
ByteBuffer bb = ByteBuffer.allocateDirect(dim * dim * 3);
for (int y = 0; y < dim; y += 1) {
for (int x = 0; x < dim; x += 1) {
int value = bitmap.getPixel(x, y);
bb.put((byte) (value >> 16));
bb.put((byte) (value >> 8));
bb.put((byte) value);
}
}
bb.rewind();
ETC1Texture compressed = ETC1Util.compressTexture(bb, dim, dim, 3, dim * 3);
FileOutputStream outFile = openFileOutput(name, Context.MODE_PRIVATE);
ETC1Util.writeTexture(compressed, outFile);
outFile.close();
}