@Override
 public ByteBuffer getPVRTextureBuffer() throws IOException {
   final InputStream inputStream = this.getInputStream();
   try {
     final byte[] data = new byte[this.mCCZHeader.getUncompressedSize()];
     StreamUtils.copy(inputStream, data);
     return ByteBuffer.wrap(data);
   } finally {
     StreamUtils.close(inputStream);
   }
 }
 /**
  * @return
  * @throws IOException
  */
 public ByteBuffer getPVRTextureBuffer() throws IOException {
   final InputStream inputStream = this.getInputStream();
   try {
     final ByteBufferOutputStream os =
         new ByteBufferOutputStream(
             DataConstants.BYTES_PER_KILOBYTE, DataConstants.BYTES_PER_MEGABYTE / 2);
     StreamUtils.copy(inputStream, os);
     return os.toByteBuffer();
   } finally {
     StreamUtils.close(inputStream);
   }
 }
Exemple #3
0
  void initializeTMXTilesFromDataString(
      final String pDataString,
      final String pDataEncoding,
      final String pDataCompression,
      final ITMXTilePropertiesListener pTMXTilePropertyListener)
      throws IOException, IllegalArgumentException {
    DataInputStream dataIn = null;
    try {
      InputStream in = new ByteArrayInputStream(pDataString.getBytes("UTF-8"));

      /* Wrap decoding Streams if necessary. */
      if (pDataEncoding != null
          && pDataEncoding.equals(TMXConstants.TAG_DATA_ATTRIBUTE_ENCODING_VALUE_BASE64)) {
        in = new Base64InputStream(in, Base64.DEFAULT);
      }
      if (pDataCompression != null) {
        if (pDataCompression.equals(TMXConstants.TAG_DATA_ATTRIBUTE_COMPRESSION_VALUE_GZIP)) {
          in = new GZIPInputStream(in);
        } else {
          throw new IllegalArgumentException(
              "Supplied compression '" + pDataCompression + "' is not supported yet.");
        }
      }
      dataIn = new DataInputStream(in);

      while (this.mTilesAdded < this.mGlobalTileIDsExpected) {
        final int globalTileID = this.readGlobalTileID(dataIn);
        this.addTileByGlobalTileID(globalTileID, pTMXTilePropertyListener);
      }
    } finally {
      StreamUtils.close(dataIn);
    }
  }
  @Override
  public final InflaterInputStream getInputStream() throws IOException {
    final InputStream inputStream = this.onGetInputStream();

    this.mCCZHeader = new CCZHeader(StreamUtils.streamToBytes(inputStream, CCZHeader.SIZE));

    return this.mCCZHeader.getCCZCompressionFormat().wrap(inputStream);
  }
  /**
   * @param pTextureManager
   * @param pPVRTextureFormat
   * @param pPVRTexturePixelBufferStrategy
   * @param pTextureOptions
   * @param pTextureStateListener
   * @throws IllegalArgumentException
   * @throws IOException
   */
  public PVRTexture(
      final TextureManager pTextureManager,
      final PVRTextureFormat pPVRTextureFormat,
      final IPVRTexturePixelBufferStrategy pPVRTexturePixelBufferStrategy,
      final TextureOptions pTextureOptions,
      final ITextureStateListener pTextureStateListener)
      throws IllegalArgumentException, IOException {
    super(
        pTextureManager,
        pPVRTextureFormat.getPixelFormat(),
        pTextureOptions,
        pTextureStateListener);
    this.mPVRTexturePixelBufferStrategy = pPVRTexturePixelBufferStrategy;

    InputStream inputStream = null;
    try {
      inputStream = this.getInputStream();
      this.mPVRTextureHeader =
          new PVRTextureHeader(StreamUtils.streamToBytes(inputStream, PVRTextureHeader.SIZE));
    } finally {
      StreamUtils.close(inputStream);
    }

    if (this.mPVRTextureHeader.getPVRTextureFormat().getPixelFormat()
        != pPVRTextureFormat.getPixelFormat()) {
      throw new IllegalArgumentException(
          "Other PVRTextureFormat: '"
              + this.mPVRTextureHeader.getPVRTextureFormat().getPixelFormat()
              + "' found than expected: '"
              + pPVRTextureFormat.getPixelFormat()
              + "'.");
    }

    if (this.mPVRTextureHeader
        .getPVRTextureFormat()
        .isCompressed()) { // TODO && ! GLHELPER_EXTENSION_PVRTC] ) {
      throw new IllegalArgumentException(
          "Invalid PVRTextureFormat: '" + this.mPVRTextureHeader.getPVRTextureFormat() + "'.");
    }

    this.mUpdateOnHardwareNeeded = true;
  }