本文整理汇总了Java中android.opengl.ETC1.encodeImage方法的典型用法代码示例。如果您正苦于以下问题:Java ETC1.encodeImage方法的具体用法?Java ETC1.encodeImage怎么用?Java ETC1.encodeImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.opengl.ETC1
的用法示例。
在下文中一共展示了ETC1.encodeImage方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setBitmap
import android.opengl.ETC1; //导入方法依赖的package包/类
public void setBitmap(Bitmap bitmap) {
mBitmap = bitmap;
int imageSize = bitmap.getRowBytes() * bitmap.getHeight();
ByteBuffer uncompressedBuffer = ByteBuffer.allocateDirect(imageSize);
bitmap.copyPixelsToBuffer(uncompressedBuffer);
uncompressedBuffer.position(0);
ByteBuffer compressedBuffer = ByteBuffer.allocateDirect(
ETC1.getEncodedDataSize(bitmap.getWidth(), bitmap.getHeight())).order(ByteOrder.nativeOrder());
ETC1.encodeImage(uncompressedBuffer, bitmap.getWidth(), bitmap.getHeight(), 2, 2 * bitmap.getWidth(),
compressedBuffer);
mByteBuffers = new ByteBuffer[]{compressedBuffer};
setWidth(bitmap.getWidth());
setHeight(bitmap.getHeight());
}
示例2: setBitmap
import android.opengl.ETC1; //导入方法依赖的package包/类
private void setBitmap(Bitmap bitmap) {
mBitmap = bitmap;
int imageSize = bitmap.getRowBytes() * bitmap.getHeight();
ByteBuffer uncompressedBuffer = ByteBuffer.allocateDirect(imageSize);
bitmap.copyPixelsToBuffer(uncompressedBuffer);
uncompressedBuffer.position(0);
ByteBuffer compressedBuffer = ByteBuffer.allocateDirect(
ETC1.getEncodedDataSize(bitmap.getWidth(), bitmap.getHeight())).order(ByteOrder.nativeOrder());
ETC1.encodeImage(uncompressedBuffer, bitmap.getWidth(), bitmap.getHeight(), 2, 2 * bitmap.getWidth(),
compressedBuffer);
setCompressionFormat(ETC1.ETC1_RGB8_OES);
mByteBuffers = new ByteBuffer[]{compressedBuffer};
setWidth(bitmap.getWidth());
setHeight(bitmap.getHeight());
}
示例3: testSDKETC1ImageCompressor
import android.opengl.ETC1; //导入方法依赖的package包/类
public static ETC1Texture testSDKETC1ImageCompressor() {
// RGB_565 is 2 bytes per pixel
ETC1.encodeImage(buffer, bitmap.getWidth(), bitmap.getHeight(), 2,
2 * bitmap.getWidth(), compressedImage);
ETC1Texture texture = new ETC1Texture(bitmap.getWidth(),
bitmap.getHeight(), compressedImage);
buffer.rewind();
// if (texture != null) {
// int estimatedMemorySize = ETC1.ETC_PKM_HEADER_SIZE
// + texture.getHeight() * texture.getWidth() / 2;
// File f = new
// File(Environment.getExternalStorageDirectory(),"bmngpkm.pkm");
// f.delete();
// f.createNewFile();
// ETC1Util.writeTexture(texture, new FileOutputStream(f));
// System.out.println("Texture PKM created ");
// }
// System.out.println("Texture PKM creation failed ");
return texture;
}
示例4: setBitmap
import android.opengl.ETC1; //导入方法依赖的package包/类
public void setBitmap(Bitmap bitmap)
{
mBitmap = bitmap;
int imageSize = bitmap.getRowBytes() * bitmap.getHeight();
ByteBuffer uncompressedBuffer = ByteBuffer.allocateDirect(imageSize);
bitmap.copyPixelsToBuffer(uncompressedBuffer);
uncompressedBuffer.position(0);
ByteBuffer compressedBuffer = ByteBuffer.allocateDirect(
ETC1.getEncodedDataSize(bitmap.getWidth(), bitmap.getHeight())).order(ByteOrder.nativeOrder());
ETC1.encodeImage(uncompressedBuffer, bitmap.getWidth(), bitmap.getHeight(), 2, 2 * bitmap.getWidth(),
compressedBuffer);
mByteBuffers = new ByteBuffer[] { compressedBuffer };
setWidth(bitmap.getWidth());
setHeight(bitmap.getHeight());
}
示例5: addEtc1Texture
import android.opengl.ETC1; //导入方法依赖的package包/类
/**
* Dynamically generates an ETC1 texture on-the-fly from given bitmap and automatically binds the newly generated
* texture.
*
* @param bitmap
* @param textureType
* @return
*/
public TextureInfo addEtc1Texture(Bitmap bitmap, TextureType textureType) {
int imageSize = bitmap.getRowBytes() * bitmap.getHeight();
ByteBuffer uncompressedBuffer = ByteBuffer.allocateDirect(imageSize);
bitmap.copyPixelsToBuffer(uncompressedBuffer);
uncompressedBuffer.position(0);
ByteBuffer compressedBuffer = ByteBuffer.allocateDirect(ETC1.getEncodedDataSize(bitmap.getWidth(), bitmap.getHeight())).order(ByteOrder.nativeOrder());
ETC1.encodeImage(uncompressedBuffer, bitmap.getWidth(), bitmap.getHeight(), 2, 2 * bitmap.getWidth(), compressedBuffer);
return addEtc1Texture(compressedBuffer, bitmap.getWidth(), bitmap.getHeight(), textureType);
}
示例6: addEtc1Texture
import android.opengl.ETC1; //导入方法依赖的package包/类
/**
* Dynamically generates an ETC1 texture on-the-fly from given bitmap and automatically binds the newly generated
* texture.
*
* @param bitmap
* @param textureType
* @return
*/
public TextureInfo addEtc1Texture(Bitmap bitmap, TextureType textureType) {
int imageSize = bitmap.getRowBytes() * bitmap.getHeight();
ByteBuffer uncompressedBuffer = ByteBuffer.allocateDirect(imageSize);
bitmap.copyPixelsToBuffer(uncompressedBuffer);
uncompressedBuffer.position(0);
ByteBuffer compressedBuffer = ByteBuffer.allocateDirect(ETC1.getEncodedDataSize(bitmap.getWidth(), bitmap.getHeight())).order(ByteOrder.nativeOrder());
ETC1.encodeImage(uncompressedBuffer, bitmap.getWidth(), bitmap.getHeight(), 2, 2 * bitmap.getWidth(), compressedBuffer);
return addEtc1Texture(compressedBuffer, bitmap.getWidth(), bitmap.getHeight(), textureType);
}
示例7: encodeTextureAsETC1_Sdk
import android.opengl.ETC1; //导入方法依赖的package包/类
public static ETC1Texture encodeTextureAsETC1_Sdk(InputStream stream)
throws IOException, FileNotFoundException {
// stream.reset();
// stream.mark(1024);
Options opts = new BitmapFactory.Options();
//opts.inPremultiplied = false;
opts.inPreferredConfig = Config.RGB_565;
Bitmap bitmap = BitmapFactory.decodeStream(stream, null, opts);
if (bitmap != null) {
ByteBuffer buffer = ByteBuffer.allocateDirect(
bitmap.getRowBytes() * bitmap.getHeight()).order(
ByteOrder.nativeOrder());
bitmap.copyPixelsToBuffer(buffer);
buffer.position(0);
System.out.println("Width : " + bitmap.getWidth());
System.out.println("Height : " + bitmap.getHeight());
System.out.println("Config : " + bitmap.getConfig());
if (bitmap.getConfig() == Bitmap.Config.ARGB_4444
|| bitmap.getConfig() == Bitmap.Config.ARGB_8888) {
System.out.println("Texture need aplha channel");
return null;
}
final int encodedImageSize = ETC1.getEncodedDataSize(
bitmap.getWidth(), bitmap.getHeight());
ByteBuffer compressedImage = ByteBuffer.allocateDirect(
encodedImageSize).order(ByteOrder.nativeOrder());
// RGB_565 is 2 bytes per pixel
ETC1.encodeImage(buffer, bitmap.getWidth(), bitmap.getHeight(),
2, 2 * bitmap.getWidth(), compressedImage);
ETC1Texture texture = new ETC1Texture(bitmap.getWidth(),
bitmap.getHeight(), compressedImage);
return texture;
}
return null;
}