本文整理汇总了Java中android.opengl.ETC1类的典型用法代码示例。如果您正苦于以下问题:Java ETC1类的具体用法?Java ETC1怎么用?Java ETC1使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ETC1类属于android.opengl包,在下文中一共展示了ETC1类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setResourceIds
import android.opengl.ETC1; //导入依赖的package包/类
public void setResourceIds(int[] resourceIds) {
ByteBuffer[] mipmapChain = new ByteBuffer[resourceIds.length];
Resources resources = TextureManager.getInstance().getContext().getResources();
int mip_0_width = 1, mip_0_height = 1;
try {
for (int i = 0, length = resourceIds.length; i < length; i++) {
ETC1Util.ETC1Texture texture = ETC1Util.createTexture(resources.openRawResource(resourceIds[i]));
mipmapChain[i] = texture.getData();
if (i == 0) {
mip_0_width = texture.getWidth();
mip_0_height = texture.getHeight();
}
}
setWidth(mip_0_width);
setHeight(mip_0_height);
setCompressionFormat(ETC1.ETC1_RGB8_OES);
} catch (IOException e) {
RajLog.e(e.getMessage());
e.printStackTrace();
}
mByteBuffers = mipmapChain;
}
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:24,代码来源:Etc1Texture.java
示例2: 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
示例3: 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
示例4: ETC1Texture
import android.opengl.ETC1; //导入依赖的package包/类
public ETC1Texture(final TextureManager pTextureManager, final TextureOptions pTextureOptions, final ITextureStateListener pTextureStateListener) throws IOException {
super(pTextureManager, PixelFormat.RGB_565, pTextureOptions, pTextureStateListener);
InputStream inputStream = null;
try {
inputStream = this.getInputStream();
this.mETC1TextureHeader = new ETC1TextureHeader(StreamUtils.streamToBytes(inputStream, ETC1.ETC_PKM_HEADER_SIZE));
if (BuildConfig.DEBUG) {
if (!(MathUtils.isPowerOfTwo(this.mETC1TextureHeader.mWidth) && MathUtils.isPowerOfTwo(this.mETC1TextureHeader.mHeight))) {
Debug.w("ETC1 textures with NPOT sizes can cause a crash on PowerVR GPUs!");
}
}
} finally {
StreamUtils.close(inputStream);
}
}
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:19,代码来源:ETC1Texture.java
示例5: ETC1TextureHeader
import android.opengl.ETC1; //导入依赖的package包/类
public ETC1TextureHeader(final byte[] pData) {
if (pData.length != ETC1.ETC_PKM_HEADER_SIZE) {
throw new IllegalArgumentException("Invalid " + this.getClass().getSimpleName() + "!");
}
this.mDataByteBuffer = ByteBuffer.allocateDirect(ETC1.ETC_PKM_HEADER_SIZE).order(ByteOrder.nativeOrder());
this.mDataByteBuffer.put(pData, 0, ETC1.ETC_PKM_HEADER_SIZE);
this.mDataByteBuffer.position(0);
if (!ETC1.isValid(this.mDataByteBuffer)) {
throw new IllegalArgumentException("Invalid " + this.getClass().getSimpleName() + "!");
}
this.mWidth = ETC1.getWidth(this.mDataByteBuffer);
this.mHeight = ETC1.getHeight(this.mDataByteBuffer);
}
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:17,代码来源:ETC1Texture.java
示例6: ETC1TextureHeader
import android.opengl.ETC1; //导入依赖的package包/类
public ETC1TextureHeader(final byte[] pData) {
if(pData.length != ETC1.ETC_PKM_HEADER_SIZE) {
throw new IllegalArgumentException("Invalid " + this.getClass().getSimpleName() + "!");
}
this.mDataByteBuffer = ByteBuffer.allocateDirect(ETC1.ETC_PKM_HEADER_SIZE).order(ByteOrder.nativeOrder());
this.mDataByteBuffer.put(pData, 0, ETC1.ETC_PKM_HEADER_SIZE);
this.mDataByteBuffer.position(0);
if (!ETC1.isValid(this.mDataByteBuffer)) {
throw new IllegalArgumentException("Invalid " + this.getClass().getSimpleName() + "!");
}
this.mWidth = ETC1.getWidth(this.mDataByteBuffer);
this.mHeight = ETC1.getHeight(this.mDataByteBuffer);
}
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:17,代码来源:ETC1Texture.java
示例7: addEtc1Texture
import android.opengl.ETC1; //导入依赖的package包/类
/**
* Add mipmap-chained ETC1 texture.
*/
public TextureInfo addEtc1Texture(int[] resourceIds, TextureType textureType, boolean isExistingTexture, WrapType wrapType, FilterType filterType) {
if (resourceIds == null) return null;
ByteBuffer[] mipmapChain = new ByteBuffer[resourceIds.length];
int mip_0_width = 1, mip_0_height = 1;
try {
for (int i = 0, length = resourceIds.length; i < length; i++) {
ETC1Util.ETC1Texture texture = ETC1Util.createTexture(mContext.getResources().openRawResource(resourceIds[i]));
mipmapChain[i] = texture.getData();
if (i == 0) {
mip_0_width = texture.getWidth();
mip_0_height = texture.getHeight();
}
}
} catch (IOException e) {
RajLog.e(e.getMessage());
e.printStackTrace();
}
return addTexture(mipmapChain, null, mip_0_width, mip_0_height, textureType, null, true, false, isExistingTexture, wrapType, filterType, CompressionType.ETC1, ETC1.ETC1_RGB8_OES);
}
开发者ID:BitMastro,项目名称:PortalLW,代码行数:24,代码来源:TextureManager.java
示例8: testSDKETC1BlockCompressor
import android.opengl.ETC1; //导入依赖的package包/类
public static byte[] testSDKETC1BlockCompressor() {
// Test android class block (reference)
byte[] in1 = { 6, 5, 7, 7, 6, 5, 9, 2, 1, 20, 5, 80, 75, 24, 96, 64,
27, 43, 45, 78, 21, 2, 85, 32, 9, 5, 7, 7, 6, 5, 9, 2, 1, 85,
5, 80, 75, 3, 96, 64, 4, 43, 45, 78, 21, 2, 7, 32 };
ByteBuffer inb = ByteBuffer.allocateDirect(48).order(
ByteOrder.nativeOrder());
inb.put(in1);
ByteBuffer out = ByteBuffer.allocateDirect(8).order(
ByteOrder.nativeOrder());
inb.rewind();
ETC1.encodeBlock(inb, mask, out);
inb.rewind();
byte[] arrayOut1 = new byte[8];
out.get(arrayOut1);
return arrayOut1;
}
开发者ID:nicastel,项目名称:renderscript_texture_compressor,代码行数:21,代码来源:ETC1Benchmarck.java
示例9: 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
示例10: writeTexture
import android.opengl.ETC1; //导入依赖的package包/类
/**
* Helper function that writes an ETC1Texture to an output stream formatted as a PKM file.
* @param texture the input texture.
* @param output the stream to write the formatted texture data to.
* @throws IOException
*/
public static void writeTexture(ETC1Texture texture, OutputStream output) throws IOException {
ByteBuffer dataBuffer = texture.getData();
dataBuffer.rewind();
System.out.println(dataBuffer.remaining());
int originalPosition = dataBuffer.position();
try {
int width = texture.getWidth();
int height = texture.getHeight();
ByteBuffer header = ByteBuffer.allocateDirect(ETC1.ETC_PKM_HEADER_SIZE).order(ByteOrder.nativeOrder());
ETC1.formatHeader(header, width, height);
header.position(0);
byte[] ioBuffer = new byte[4096];
header.get(ioBuffer, 0, ETC1.ETC_PKM_HEADER_SIZE);
output.write(ioBuffer, 0, ETC1.ETC_PKM_HEADER_SIZE);
while (dataBuffer.remaining()>0) {
int chunkSize = Math.min(ioBuffer.length, dataBuffer.remaining());
dataBuffer.get(ioBuffer, 0, chunkSize);
output.write(ioBuffer, 0, chunkSize);
}
} finally {
dataBuffer.position(originalPosition);
}
}
开发者ID:nicastel,项目名称:renderscript_texture_compressor,代码行数:30,代码来源:RsETC1Util.java
示例11: setResourceIds
import android.opengl.ETC1; //导入依赖的package包/类
public void setResourceIds(int[] resourceIds)
{
ByteBuffer[] mipmapChain = new ByteBuffer[resourceIds.length];
Resources resources = TextureManager.getInstance().getContext().getResources();
int mip_0_width = 1, mip_0_height = 1;
try {
for (int i = 0, length = resourceIds.length; i < length; i++) {
ETC1Util.ETC1Texture texture = ETC1Util.createTexture(resources.openRawResource(resourceIds[i]));
mipmapChain[i] = texture.getData();
if (i == 0) {
mip_0_width = texture.getWidth();
mip_0_height = texture.getHeight();
}
}
setWidth(mip_0_width);
setHeight(mip_0_height);
setCompressionFormat(ETC1.ETC1_RGB8_OES);
} catch (IOException e) {
RajLog.e(e.getMessage());
e.printStackTrace();
}
mByteBuffers = mipmapChain;
}
开发者ID:takyonxxx,项目名称:IRobot-Android,代码行数:25,代码来源:Etc1Texture.java
示例12: 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
示例13: addEtc1Texture
import android.opengl.ETC1; //导入依赖的package包/类
/**
* Add mipmap-chained ETC1 texture.
* @param context
* @param resourceIds
* @return
*/
public TextureInfo addEtc1Texture(int[] resourceIds, TextureType textureType, boolean isExistingTexture, WrapType wrapType, FilterType filterType) {
if (resourceIds == null) return null;
ByteBuffer[] mipmapChain = new ByteBuffer[resourceIds.length];
int mip_0_width = 1, mip_0_height = 1;
try {
for (int i = 0, length = resourceIds.length; i < length; i++) {
ETC1Util.ETC1Texture texture = ETC1Util.createTexture(mContext.getResources().openRawResource(resourceIds[i]));
mipmapChain[i] = texture.getData();
if (i == 0) {
mip_0_width = texture.getWidth();
mip_0_height = texture.getHeight();
}
}
} catch (IOException e) {
RajLog.e(e.getMessage());
e.printStackTrace();
}
return addTexture(mipmapChain, null, mip_0_width, mip_0_height, textureType, null, true, false, isExistingTexture, wrapType, filterType, CompressionType.ETC1, ETC1.ETC1_RGB8_OES);
}
开发者ID:OpsLabJPL,项目名称:MarsImagesAndroid,代码行数:27,代码来源:TextureManager.java
示例14: createTexture
import android.opengl.ETC1; //导入依赖的package包/类
/**
* Create a new ETC2Texture from an input stream containing a PKM formatted compressed texture.
*
* @param input an input stream containing a PKM formatted compressed texture.
*
* @return an ETC2Texture read from the input stream.
* @throws IOException
*/
public static ETC2Texture createTexture(InputStream input) throws IOException {
int width = 0;
int height = 0;
int format = -1;
byte[] ioBuffer = new byte[4096];
// We can use the ETC1 header size as it is the same
if (input.read(ioBuffer, 0, ETC1.ETC_PKM_HEADER_SIZE) != ETC1.ETC_PKM_HEADER_SIZE) {
throw new IOException("Unable to read PKM file header.");
}
final ByteBuffer headerBuffer = ByteBuffer.allocateDirect(ETC1.ETC_PKM_HEADER_SIZE)
.order(ByteOrder.BIG_ENDIAN);
headerBuffer.put(ioBuffer, 0, ETC1.ETC_PKM_HEADER_SIZE).position(0);
if (!ETC2.isValid(headerBuffer)) {
throw new IOException("Not a PKM file.");
}
width = ETC2.getWidth(headerBuffer);
height = ETC2.getHeight(headerBuffer);
format = ETC2.getETC2CompressionType(headerBuffer);
final int encodedSize = ETC2.getEncodedDataSize(width, height);
final ByteBuffer dataBuffer = ByteBuffer.allocateDirect(encodedSize).order(ByteOrder.BIG_ENDIAN);
for (int i = 0; i < encodedSize; ) {
int chunkSize = Math.min(ioBuffer.length, encodedSize - i);
if (input.read(ioBuffer, 0, chunkSize) != chunkSize) {
throw new IOException("Unable to read PKM file data.");
}
dataBuffer.put(ioBuffer, 0, chunkSize);
i += chunkSize;
}
dataBuffer.position(0);
return new ETC2Texture(format, width, height, dataBuffer);
}
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:41,代码来源:ETC2Util.java
示例15: setResourceId
import android.opengl.ETC1; //导入依赖的package包/类
public void setResourceId(int resourceId) {
mResourceId = resourceId;
Resources resources = TextureManager.getInstance().getContext().getResources();
try {
ETC1Util.ETC1Texture texture = ETC1Util.createTexture(resources.openRawResource(resourceId));
mByteBuffers = new ByteBuffer[]{texture.getData()};
setWidth(texture.getWidth());
setHeight(texture.getHeight());
setCompressionFormat(ETC1.ETC1_RGB8_OES);
} catch (IOException e) {
RajLog.e(e.getMessage());
e.printStackTrace();
}
}
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:15,代码来源:Etc1Texture.java
示例16: ETC1Texture
import android.opengl.ETC1; //导入依赖的package包/类
public ETC1Texture(final TextureManager pTextureManager, final TextureOptions pTextureOptions, final ITextureStateListener pTextureStateListener) throws IOException {
super(pTextureManager, PixelFormat.RGB_565, pTextureOptions, pTextureStateListener);
InputStream inputStream = null;
try {
inputStream = this.getInputStream();
this.mETC1TextureHeader = new ETC1TextureHeader(StreamUtils.streamToBytes(inputStream, ETC1.ETC_PKM_HEADER_SIZE));
} finally {
StreamUtils.close(inputStream);
}
}
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:13,代码来源:ETC1Texture.java
示例17: showEtc1Texture
import android.opengl.ETC1; //导入依赖的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
示例18: loadTexture
import android.opengl.ETC1; //导入依赖的package包/类
/**
* Convenience method to load an ETC1 texture whether or not the active OpenGL context
* supports the ETC1 texture compression format.
* @param target the texture target.
* @param level the texture level
* @param border the border size. Typically 0.
* @param fallbackFormat the format to use if ETC1 texture compression is not supported.
* Must be GL_RGB.
* @param fallbackType the type to use if ETC1 texture compression is not supported.
* Can be either GL_UNSIGNED_SHORT_5_6_5, which implies 16-bits-per-pixel,
* or GL_UNSIGNED_BYTE, which implies 24-bits-per-pixel.
* @param texture the ETC1 to load.
*/
public static void loadTexture(int target, int level, int border,
int fallbackFormat, int fallbackType, ETC1Texture texture) {
if (fallbackFormat != GLES10.GL_RGB) {
throw new IllegalArgumentException("fallbackFormat must be GL_RGB");
}
if (! (fallbackType == GLES10.GL_UNSIGNED_SHORT_5_6_5
|| fallbackType == GLES10.GL_UNSIGNED_BYTE)) {
throw new IllegalArgumentException("Unsupported fallbackType");
}
int width = texture.getWidth();
int height = texture.getHeight();
Buffer data = texture.getData();
if (isETC1Supported()) {
int imageSize = data.remaining();
GLES10.glCompressedTexImage2D(target, level, RsETC1.ETC1_RGB8_OES, width, height,
border, imageSize, data);
} else {
boolean useShorts = fallbackType != GLES10.GL_UNSIGNED_BYTE;
int pixelSize = useShorts ? 2 : 3;
int stride = pixelSize * width;
ByteBuffer decodedData = ByteBuffer.allocateDirect(stride*height)
.order(ByteOrder.nativeOrder());
ETC1.decodeImage((ByteBuffer) data, decodedData, width, height, pixelSize, stride);
GLES10.glTexImage2D(target, level, fallbackFormat, width, height, border,
fallbackFormat, fallbackType, decodedData);
}
}
开发者ID:nicastel,项目名称:renderscript_texture_compressor,代码行数:42,代码来源:RsETC1Util.java
示例19: createTexture
import android.opengl.ETC1; //导入依赖的package包/类
/**
* Create a new ETC1Texture from an input stream containing a PKM formatted compressed texture.
* @param input an input stream containing a PKM formatted compressed texture.
* @return an ETC1Texture read from the input stream.
* @throws IOException
*/
public static ETC1Texture createTexture(InputStream input) throws IOException {
int width = 0;
int height = 0;
byte[] ioBuffer = new byte[4096];
{
if (input.read(ioBuffer, 0, ETC1.ETC_PKM_HEADER_SIZE) != ETC1.ETC_PKM_HEADER_SIZE) {
throw new IOException("Unable to read PKM file header.");
}
ByteBuffer headerBuffer = ByteBuffer.allocateDirect(ETC1.ETC_PKM_HEADER_SIZE)
.order(ByteOrder.nativeOrder());
headerBuffer.put(ioBuffer, 0, ETC1.ETC_PKM_HEADER_SIZE).position(0);
if (!ETC1.isValid(headerBuffer)) {
throw new IOException("Not a PKM file.");
}
width = ETC1.getWidth(headerBuffer);
height = ETC1.getHeight(headerBuffer);
}
int encodedSize = ETC1.getEncodedDataSize(width, height);
ByteBuffer dataBuffer = ByteBuffer.allocateDirect(encodedSize).order(ByteOrder.nativeOrder());
for (int i = 0; i < encodedSize; ) {
int chunkSize = Math.min(ioBuffer.length, encodedSize - i);
if (input.read(ioBuffer, 0, chunkSize) != chunkSize) {
throw new IOException("Unable to read PKM file data.");
}
dataBuffer.put(ioBuffer, 0, chunkSize);
i += chunkSize;
}
dataBuffer.position(0);
return new ETC1Texture(width, height, dataBuffer);
}
开发者ID:nicastel,项目名称:renderscript_texture_compressor,代码行数:37,代码来源:RsETC1Util.java
示例20: setResourceId
import android.opengl.ETC1; //导入依赖的package包/类
public void setResourceId(int resourceId) {
mResourceId = resourceId;
Resources resources = TextureManager.getInstance().getContext().getResources();
try {
ETC1Util.ETC1Texture texture = ETC1Util.createTexture(resources.openRawResource(resourceId));
mByteBuffers = new ByteBuffer[] { texture.getData() };
setWidth(texture.getWidth());
setHeight(texture.getHeight());
setCompressionFormat(ETC1.ETC1_RGB8_OES);
} catch (IOException e) {
RajLog.e(e.getMessage());
e.printStackTrace();
}
}
开发者ID:takyonxxx,项目名称:IRobot-Android,代码行数:15,代码来源:Etc1Texture.java
注:本文中的android.opengl.ETC1类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论