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


Java ETC1Util类代码示例

本文整理汇总了Java中android.opengl.ETC1Util的典型用法代码示例。如果您正苦于以下问题:Java ETC1Util类的具体用法?Java ETC1Util怎么用?Java ETC1Util使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ETC1Util类属于android.opengl包,在下文中一共展示了ETC1Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setResourceIds

import android.opengl.ETC1Util; //导入依赖的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: setInputStream

import android.opengl.ETC1Util; //导入依赖的package包/类
public void setInputStream(InputStream compressedTexture, Bitmap fallbackTexture) {
    ETC1Util.ETC1Texture texture = null;

    try {
        texture = ETC1Util.createTexture(compressedTexture);
    } catch (IOException e) {
        RajLog.e("addEtc1Texture: " + e.getMessage());
    } finally {
        if (texture == null) {
            setBitmap(fallbackTexture);

            if (RajLog.isDebugEnabled())
                RajLog.d("Falling back to uncompressed texture");
        } else {
            setByteBuffer(texture.getData());
            setWidth(texture.getWidth());
            setHeight(texture.getHeight());

            if (RajLog.isDebugEnabled())
                RajLog.d("ETC1 texture load successful");
        }
    }
}
 
开发者ID:sujitkjha,项目名称:360-Video-Player-for-Android,代码行数:24,代码来源:Etc1Texture.java

示例3: load

import android.opengl.ETC1Util; //导入依赖的package包/类
public void load(GL10 gl) {
    int width = 128;
    int height = 128;
    Buffer image = createImage(width, height);
    ETC1Util.ETC1Texture etc1Texture = ETC1Util.compressTexture(image, width, height, 3, 3 * width);
    if (USE_STREAM_IO) {
        // Test the ETC1Util APIs for reading and writing compressed textures to I/O streams.
        try {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            ETC1Util.writeTexture(etc1Texture, bos);
            ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
            ETC1Util.loadTexture(GLES10.GL_TEXTURE_2D, 0, 0,
                    GLES10.GL_RGB, GLES10.GL_UNSIGNED_SHORT_5_6_5, bis);
        } catch (IOException e) {
            Log.w(TAG, "Could not load texture: " + e);
        }
    } else {
        ETC1Util.loadTexture(GLES10.GL_TEXTURE_2D, 0, 0,
                GLES10.GL_RGB, GLES10.GL_UNSIGNED_SHORT_5_6_5, etc1Texture);
    }
}
 
开发者ID:luoqii,项目名称:ApkLauncher,代码行数:22,代码来源:CompressedTextureActivity.java

示例4: addEtc1Texture

import android.opengl.ETC1Util; //导入依赖的package包/类
public TextureInfo addEtc1Texture(InputStream compressedTex, Bitmap fallbackTex, TextureType textureType) {
    ETC1Util.ETC1Texture texture = null;
    TextureInfo textureInfo = null;
    try {
        texture = ETC1Util.createTexture(compressedTex);
    } catch (IOException e) {
        Log.e("addEtc1Texture", e.getMessage());
    } finally {
        if (texture == null) {
            textureInfo = addTexture(fallbackTex);
            Log.d("ETC1", "Falling back to uncompressed texture");
        } else {
            textureInfo = addEtc1Texture(texture.getData(), texture.getWidth(), texture.getHeight(), textureType);
            Log.d("ETC1", "ETC1 texture load successful");
        }
    }

    return textureInfo;
}
 
开发者ID:BitMastro,项目名称:PortalLW,代码行数:20,代码来源:TextureManager.java

示例5: setResourceIds

import android.opengl.ETC1Util; //导入依赖的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

示例6: setInputStream

import android.opengl.ETC1Util; //导入依赖的package包/类
public void setInputStream(InputStream compressedTexture, Bitmap fallbackTexture)
{
	ETC1Util.ETC1Texture texture = null;

	try {
		texture = ETC1Util.createTexture(compressedTexture);
	} catch (IOException e) {
		Log.e("addEtc1Texture", e.getMessage());
	} finally {
		if (texture == null) {
			setBitmap(fallbackTexture);
			Log.d("ETC1", "Falling back to uncompressed texture");
		} else {
			setByteBuffer(texture.getData());
			setWidth(texture.getWidth());
			setHeight(texture.getHeight());
			Log.d("ETC1", "ETC1 texture load successful");
		}
	}
}
 
开发者ID:takyonxxx,项目名称:IRobot-Android,代码行数:21,代码来源:Etc1Texture.java

示例7: loadTexture

import android.opengl.ETC1Util; //导入依赖的package包/类
/**
    * Load a texture from filesystem and bind it to texture
    *
    * @param gl
    * @param tex
    * @param name
    * @throws IOException
    */
public void loadTexture(GL10 gl, int tex, String name) throws IOException {
	gl.glBindTexture(GL10.GL_TEXTURE_2D, tex);
    gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
    gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
    gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
    gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);

    InputStream textureStream;
    if (context.getFileStreamPath(name).exists()) {
    	textureStream = context.openFileInput(name);
    } else {
    	textureStream = context.getAssets().open(name);
    }

    ETC1Util.loadTexture(GL10.GL_TEXTURE_2D, 0, 0, GL10.GL_RGB, GL10.GL_UNSIGNED_SHORT_5_6_5, textureStream);
    textureStream.close();
}
 
开发者ID:alankila,项目名称:live-mandelbox,代码行数:26,代码来源:ProjectionRenderer.java

示例8: makeImage

import android.opengl.ETC1Util; //导入依赖的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

示例9: addEtc1Texture

import android.opengl.ETC1Util; //导入依赖的package包/类
public TextureInfo addEtc1Texture(InputStream compressedTex, Bitmap fallbackTex, TextureType textureType) {
	ETC1Util.ETC1Texture texture = null;
	TextureInfo textureInfo = null;
	try {
		texture = ETC1Util.createTexture(compressedTex);
	} catch (IOException e) {
		Log.e("addEtc1Texture", e.getMessage());
	} finally {
		if (texture == null) {
			textureInfo = addTexture(fallbackTex);
			Log.d("ETC1", "Falling back to uncompressed texture");
		} else {
			textureInfo = addEtc1Texture(texture.getData(), texture.getWidth(), texture.getHeight(), textureType);
			Log.d("ETC1", "ETC1 texture load successful");
		}
	}
	
	return textureInfo;
}
 
开发者ID:OpsLabJPL,项目名称:MarsImagesAndroid,代码行数:20,代码来源:TextureManager.java

示例10: loadTexture

import android.opengl.ETC1Util; //导入依赖的package包/类
private void loadTexture(Context context, Render.DrawGroup drawGroup) {
    if (drawGroup.texture != null) {
        int resource = TEXTURES.get(drawGroup.texture.toLowerCase());

        InputStream is = context.getResources().openRawResource(resource);
        try {
            ETC1Util.ETC1Texture tex = ETC1Util.createTexture(is);
            is.close();
            drawGroup.loadedCompressedDiffuseTexture = tex;
        } catch (IOException e) {
            Log.e("Body", "Loading texture: " + e);
        }
    } else {
        int[] color = { Color.rgb(
                (int)(drawGroup.diffuseColor[0] * 255 + 0.5),
                (int)(drawGroup.diffuseColor[1] * 255 + 0.5),
                (int)(drawGroup.diffuseColor[2] * 255 + 0.5))
        };
        Bitmap bitmap = Bitmap.createBitmap(color, 1, 1, Bitmap.Config.RGB_565);
        drawGroup.loadedDiffuseTexture = bitmap;
    }
}
 
开发者ID:frydsh,项目名称:GoogleBody,代码行数:23,代码来源:LayersLoader.java

示例11: setResourceId

import android.opengl.ETC1Util; //导入依赖的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

示例12: setResourceId

import android.opengl.ETC1Util; //导入依赖的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

示例13: loadTexture

import android.opengl.ETC1Util; //导入依赖的package包/类
public static int loadTexture(ETC1Util.ETC1Texture etc1Texture) {
    // Note that unlike the js version, this does not cache textures. There
    // was just one cache hit.
    int tex = genTex();
    GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex);
    ETC1Util.loadTexture(
            GLES20.GL_TEXTURE_2D, 0, 0, GLES20.GL_RGB,
            GLES20.GL_UNSIGNED_SHORT_5_6_5, etc1Texture);

    return tex;
}
 
开发者ID:frydsh,项目名称:GoogleBody,代码行数:12,代码来源:Textures.java

示例14: writeTextureToHardware

import android.opengl.ETC1Util; //导入依赖的package包/类
@Override
protected void writeTextureToHardware(final GLState pGLState) throws IOException {
	final InputStream inputStream = this.getInputStream();
	ETC1Util.loadTexture(GLES20.GL_TEXTURE_2D, 0, 0, this.mPixelFormat.getGLFormat(), this.mPixelFormat.getGLType(), inputStream);
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:6,代码来源:ETC1Texture.java

示例15: determineGraphicSupport

import android.opengl.ETC1Util; //导入依赖的package包/类
public void determineGraphicSupport(GL10 gl) {

            final String extensions = gl.glGetString(GL10.GL_EXTENSIONS);
            final String version = GLES10.glGetString(GL10.GL_VERSION);
            final String renderer = gl.glGetString(GL10.GL_RENDERER);

            Log.w("GLExtensions", "Extensions: " + extensions);
            Log.w("GLVersion", "Version: " + version);
            Log.w("GLRenderer", "Renderer: " + renderer);
            // GL_EXT_debug_marker GL_OES_blend_func_separate GL_OES_blend_equation_separate GL_OES_blend_subtract
            // GL_OES_byte_coordinates GL_OES_compressed_paletted_texture GL_OES_point_size_array GL_OES_point_sprite
            // GL_OES_single_precision GL_OES_stencil_wrap GL_OES_texture_env_crossbar GL_OES_texture_mirored_repeat
            // GL_OES_EGL_image GL_OES_element_index_uint GL_OES_draw_texture GL_OES_texture_cube_map GL_OES_draw_texture
            // GL_OES_read_format GL_OES_framebuffer_object GL_OES_depth24 GL_OES_depth32 GL_OES_fbo_render_mipmap
            // GL_OES_rgb8_rgba8 GL_OES_stencil1 GL_OES_stencil4 GL_OES_stencil8
            // GL_OES_packed_depth_stencil GL_EXT_texture_format_BGRA8888 GL_APPLE_texture_format_BGRA8888
            // GL_OES_compressed_ETC1_RGB8_texture
            String enabledCompressions = "";
            if (extensions.contains("GL_IMG_texture_compression_pvrtc")) {
                //Use PVR compressed textures
                Log.w("Ext", "Device supports PVR");
                enabledCompressions += "Device supports PVR\n\t";
            }
            if (extensions.contains("GL_AMD_compressed_ATC_texture") ||
                    extensions.contains("GL_ATI_texture_compression_atitc")) {
                //Load ATI Textures
                Log.w("Ext", "Device supports ATI");
                enabledCompressions += "Device supports ATI\n\t";
            }
            if (extensions.contains("GL_OES_texture_compression_S3TC") ||
                    extensions.contains("GL_EXT_texture_compression_s3tc")) {
                //Use DTX Textures
                Log.w("Ext", "Device supports S3TC");
                enabledCompressions += "Device supports S3TC\n\t";
            }
            if (extensions.contains("GL_EXT_texture_compression_dxt1")) {
                //Use DTX1 Textures
                Log.w("Ext", "Device supports DXT1");
                enabledCompressions += "Device supports DXT1\n\t";
            }
            if (extensions.contains("GL_EXT_texture_compression_dxt3")) {
                //Use DTX3 Textures
                Log.w("Ext", "Device supports DXT3");
                enabledCompressions += "Device supports DXT3\n\t";
            }
            if (extensions.contains("GL_EXT_texture_compression_dxt5")) {
                //Use DTX5 Textures
                Log.w("Ext", "Device supports DXT5");
                enabledCompressions += "Device supports DXT5\n\t";
            }
            if (extensions.contains("GL_AMD_compressed_3DC_texture")) {
                //Use 3DC Texture
                Log.w("Ext", "Device supports 3DC textures");
                enabledCompressions += "Device supports 3DC textures\n\t";
            }
            if (ETC1Util.isETC1Supported()) {
                //Use ETC1
                Log.w("Ext", "Device supports ETC1 Rgb8 textures");
                enabledCompressions += "Device supports ETC1 Rgb8 textures\n\t";
            }
            final String enabComprFinal = enabledCompressions;
            String[] extArray = extensions.split(" ");
            final List<String> ordered = Arrays.asList(extArray);
            Collections.sort(ordered);
            CheckerActivity.this.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    String extFormatted = "";
                    for (String singleExt : ordered) {
                        extFormatted += singleExt + "\n\t";
                    }
                    glExtensionsTv.setText("Extensions: \n\t" + extFormatted);
                    glVersionTv.setText("Version: " + version);
                    glRendererTv.setText("Renderer: " + renderer);
                    glExtensionsEnabled.setText("Texture Compression Supported: \n\t" + enabComprFinal);
                }
            });
        }
 
开发者ID:ndorigatti,项目名称:GLExtensionsChecker,代码行数:79,代码来源:CheckerActivity.java


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