本文整理汇总了Java中android.opengl.ETC1Util.ETC1Texture类的典型用法代码示例。如果您正苦于以下问题:Java ETC1Texture类的具体用法?Java ETC1Texture怎么用?Java ETC1Texture使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ETC1Texture类属于android.opengl.ETC1Util包,在下文中一共展示了ETC1Texture类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSDKETC1ImageCompressor
import android.opengl.ETC1Util.ETC1Texture; //导入依赖的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;
}
示例2: testJavaETC1ImageCompressor
import android.opengl.ETC1Util.ETC1Texture; //导入依赖的package包/类
public static ETC1Texture testJavaETC1ImageCompressor() {
// RGB_565 is 2 bytes per pixel
JavaETC1.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;
}
示例3: makeImage
import android.opengl.ETC1Util.ETC1Texture; //导入依赖的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();
}
示例4: showEtc1Texture
import android.opengl.ETC1Util.ETC1Texture; //导入依赖的package包/类
public void showEtc1Texture(ETC1Texture texture) {
int width = texture.getWidth();
int height = texture.getHeight();
Buffer data = texture.getData();
int pixelSize = 2;
int stride = pixelSize * width;
ByteBuffer decodedData = ByteBuffer.allocateDirect(stride*height)
.order(ByteOrder.nativeOrder());
ETC1.decodeImage((ByteBuffer) data, decodedData, width, height, pixelSize, stride);
mBitmapOut.copyPixelsFromBuffer(decodedData);
mDisplayView.invalidate();
}
示例5: testRsETC1ImageCompressor
import android.opengl.ETC1Util.ETC1Texture; //导入依赖的package包/类
public static ETC1Texture testRsETC1ImageCompressor(RenderScript rs,
ScriptC_etc1compressor script) {
Allocation alloc = Allocation.createFromBitmap(rs, bitmapARGB, MipmapControl.MIPMAP_NONE, Allocation.USAGE_SHARED);
// RGB_565 is 2 bytes per pixel
RsETC1.encodeImage(rs, script, alloc, bitmapARGB.getWidth(), bitmapARGB.getHeight(), 4,
4 * bitmapARGB.getWidth(), compressedImage, null, false, false);
ETC1Texture texture = new ETC1Texture(bitmapARGB.getWidth(),
bitmapARGB.getHeight(), compressedImage);
alloc.destroy();
// 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;
}
示例6: testRsETC1ImageCompressorWithAlpha
import android.opengl.ETC1Util.ETC1Texture; //导入依赖的package包/类
public static ETC1Texture testRsETC1ImageCompressorWithAlpha(RenderScript rs,
ScriptC_etc1compressor script) {
Allocation alloc = Allocation.createFromBitmap(rs, bitmapARGB, MipmapControl.MIPMAP_NONE, Allocation.USAGE_SHARED);
// RGB_565 is 2 bytes per pixel
RsETC1.encodeImage(rs, script, alloc, bitmapARGB.getWidth(), bitmapARGB.getHeight(), 4,
4 * bitmapARGB.getWidth(), compressedImage, compressedImageAlpha, false, true);
ETC1Texture texture = new ETC1Texture(bitmapARGB.getWidth(),
bitmapARGB.getHeight(), compressedImage);
alloc.destroy();
// 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;
}
示例7: encodeTextureAsETC1_Sdk
import android.opengl.ETC1Util.ETC1Texture; //导入依赖的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;
}
示例8: encodeTextureAsETC1_Java
import android.opengl.ETC1Util.ETC1Texture; //导入依赖的package包/类
public static ETC1Texture encodeTextureAsETC1_Java(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 = JavaETC1.getEncodedDataSize(
bitmap.getWidth(), bitmap.getHeight());
ByteBuffer compressedImage = ByteBuffer.allocateDirect(
encodedImageSize).order(ByteOrder.nativeOrder());
// RGB_565 is 2 bytes per pixel
JavaETC1.encodeImage(buffer, bitmap.getWidth(), bitmap.getHeight(),
2, 2 * bitmap.getWidth(), compressedImage);
ETC1Texture texture = new ETC1Texture(bitmap.getWidth(),
bitmap.getHeight(), compressedImage);
return texture;
}
return null;
}