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()); }
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()); } }
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()); }
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()); } }