try { ETC1Util.ETC1Texture texture = ETC1Util.createTexture(resources.openRawResource(mResourceId)); mByteBuffers = new ByteBuffer[]{texture.getData()}; setWidth(texture.getWidth()); setHeight(texture.getHeight()); for (int i = 0, length = mResourceIds.length; i < length; i++) { ETC1Util.ETC1Texture texture = ETC1Util.createTexture(resources.openRawResource(mResourceIds[i])); mipmapChain[i] = texture.getData(); if (i == 0) { mip_0_width = texture.getWidth();
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"); } } } }
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(); } }
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"); } } } }
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; }