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


Java ETC1.encodeImage方法代码示例

本文整理汇总了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());
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:17,代码来源:Etc1Texture.java

示例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());
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:18,代码来源:Etc2Texture.java

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

示例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());
}
 
开发者ID:takyonxxx,项目名称:IRobot-Android,代码行数:18,代码来源:Etc1Texture.java

示例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);
}
 
开发者ID:BitMastro,项目名称:PortalLW,代码行数:20,代码来源:TextureManager.java

示例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);
}
 
开发者ID:OpsLabJPL,项目名称:MarsImagesAndroid,代码行数:20,代码来源:TextureManager.java

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


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