当前位置: 首页>>代码示例>>Java>>正文


Java ETC1Texture类代码示例

本文整理汇总了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;
	}
 
开发者ID:nicastel,项目名称:renderscript_texture_compressor,代码行数:26,代码来源:ETC1Benchmarck.java

示例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;
}
 
开发者ID:nicastel,项目名称:renderscript_texture_compressor,代码行数:24,代码来源:ETC1Benchmarck.java

示例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();
}
 
开发者ID:alankila,项目名称:live-mandelbox,代码行数:21,代码来源:ViewUpdateService.java

示例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();
}
 
开发者ID:nicastel,项目名称:renderscript_texture_compressor,代码行数:14,代码来源:MainActivity.java

示例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;
}
 
开发者ID:nicastel,项目名称:renderscript_texture_compressor,代码行数:29,代码来源:ETC1Benchmarck.java

示例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;
}
 
开发者ID:nicastel,项目名称:renderscript_texture_compressor,代码行数:29,代码来源:ETC1Benchmarck.java

示例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;
}
 
开发者ID:nicastel,项目名称:renderscript_texture_compressor,代码行数:42,代码来源:PKMEncoder.java

示例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;
}
 
开发者ID:nicastel,项目名称:renderscript_texture_compressor,代码行数:42,代码来源:PKMEncoder.java


注:本文中的android.opengl.ETC1Util.ETC1Texture类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。