If you think the Android project DivisionByZero listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.ggstudios.utils;
//www.java2s.comimport android.graphics.Bitmap;
import android.opengl.GLES20;
import android.opengl.GLUtils;
publicclass BitmapUtils {
publicstaticint loadBitmap(Bitmap bitmap) {
return loadBitmap(bitmap, -1, true);
}
publicstaticint loadBitmap(Bitmap bitmap, int oldHandle) {
return loadBitmap(bitmap, oldHandle, true);
}
/**
* Loads a bitmap into memory then discards the bitmap.
* @param bitmap
* @param oldHandle Handle to use.
* @return
*/publicstaticint loadBitmap(Bitmap bitmap, int oldHandle, boolean recycle) {
int h;
int handle[] = newint[1];
GLES20.glGenTextures(1, handle, 0);
h = handle[0];
//
// if(oldHandle <= 0) {
// int handle[] = new int[1];
// GLES20.glGenTextures(1, handle, 0);
// h = handle[0];
// } else {
// h = oldHandle;
// }
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, h);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
if(recycle)
bitmap.recycle();
return h;
}
}