Java 类com.bumptech.glide.gifdecoder.GifHeaderParser 实例源码

项目:tumblr3d    文件:GifResourceDecoder.java   
private GifTextureResource decode(byte[] data, int width, int height, GifHeaderParser parser, GifDecoder decoder) {
    final GifHeader header = parser.parseHeader();
    if (header.getNumFrames() <= 0 || header.getStatus() != GifDecoder.STATUS_OK) {
        // If we couldn't decode the GIF, we will end up with a frame count of 0.
        return null;
    }

    Bitmap firstFrame = decodeFirstFrame(decoder, header, data);
    if (firstFrame == null) {
        return null;
    }

    Transformation<Bitmap> unitTransformation = UnitTransformation.get();

    GifTexture gifDrawable = new GifTexture(context, provider, bitmapPool, unitTransformation, width, height,
            header, data, firstFrame);

    return new GifTextureResource(gifDrawable);
}
项目:GitHub    文件:ReEncodingGifResourceEncoder.java   
private GifDecoder decodeHeaders(ByteBuffer data) {
  GifHeaderParser parser = factory.buildParser();
  parser.setData(data);
  GifHeader header = parser.parseHeader();

  GifDecoder decoder = factory.buildDecoder(provider);
  decoder.setData(header, data);
  decoder.advance();

  return decoder;
}
项目:GitHub    文件:ByteBufferGifDecoder.java   
@Override
public GifDrawableResource decode(ByteBuffer source, int width, int height, Options options) {
  final GifHeaderParser parser = parserPool.obtain(source);
  try {
    return decode(source, width, height, parser);
  } finally {
    parserPool.release(parser);
  }
}
项目:GitHub    文件:ByteBufferGifDecoder.java   
private GifDrawableResource decode(ByteBuffer byteBuffer, int width, int height,
    GifHeaderParser parser) {
  long startTime = LogTime.getLogTime();
  final GifHeader header = parser.parseHeader();
  if (header.getNumFrames() <= 0 || header.getStatus() != GifDecoder.STATUS_OK) {
    // If we couldn't decode the GIF, we will end up with a frame count of 0.
    return null;
  }


  int sampleSize = getSampleSize(header, width, height);
  GifDecoder gifDecoder = gifDecoderFactory.build(provider, header, byteBuffer, sampleSize);
  gifDecoder.advance();
  Bitmap firstFrame = gifDecoder.getNextFrame();
  if (firstFrame == null) {
    return null;
  }

  Transformation<Bitmap> unitTransformation = UnitTransformation.get();

  GifDrawable gifDrawable =
      new GifDrawable(context, gifDecoder, bitmapPool, unitTransformation, width, height,
          firstFrame);

  if (Log.isLoggable(TAG, Log.VERBOSE)) {
    Log.v(TAG, "Decoded GIF from stream in " + LogTime.getElapsedMillis(startTime));
  }

  return new GifDrawableResource(gifDrawable);
}
项目:GitHub    文件:ReEncodingGifResourceEncoder.java   
private GifDecoder decodeHeaders(ByteBuffer data) {
  GifHeaderParser parser = factory.buildParser();
  parser.setData(data);
  GifHeader header = parser.parseHeader();

  GifDecoder decoder = factory.buildDecoder(provider);
  decoder.setData(header, data);
  decoder.advance();

  return decoder;
}
项目:GitHub    文件:ByteBufferGifDecoder.java   
@Override
public GifDrawableResource decode(ByteBuffer source, int width, int height, Options options) {
  final GifHeaderParser parser = parserPool.obtain(source);
  try {
    return decode(source, width, height, parser, options);
  } finally {
    parserPool.release(parser);
  }
}
项目:GitHub    文件:ByteBufferGifDecoder.java   
private GifDrawableResource decode(
    ByteBuffer byteBuffer, int width, int height, GifHeaderParser parser, Options options) {
  long startTime = LogTime.getLogTime();
  final GifHeader header = parser.parseHeader();
  if (header.getNumFrames() <= 0 || header.getStatus() != GifDecoder.STATUS_OK) {
    // If we couldn't decode the GIF, we will end up with a frame count of 0.
    return null;
  }

  Bitmap.Config config = options.get(GifOptions.DECODE_FORMAT) == DecodeFormat.PREFER_RGB_565
      ? Bitmap.Config.RGB_565 : Bitmap.Config.ARGB_8888;

  int sampleSize = getSampleSize(header, width, height);
  GifDecoder gifDecoder = gifDecoderFactory.build(provider, header, byteBuffer, sampleSize);
  gifDecoder.setDefaultBitmapConfig(config);
  gifDecoder.advance();
  Bitmap firstFrame = gifDecoder.getNextFrame();
  if (firstFrame == null) {
    return null;
  }

  Transformation<Bitmap> unitTransformation = UnitTransformation.get();

  GifDrawable gifDrawable =
      new GifDrawable(context, gifDecoder, unitTransformation, width, height, firstFrame);

  if (Log.isLoggable(TAG, Log.VERBOSE)) {
    Log.v(TAG, "Decoded GIF from stream in " + LogTime.getElapsedMillis(startTime));
  }

  return new GifDrawableResource(gifDrawable);
}
项目:saarang-iosched    文件:GifResourceDecoder.java   
@Override
public GifDataResource decode(InputStream source, int width, int height) throws IOException {
    byte[] data = inputStreamToBytes(source);
    GifHeader header = new GifHeaderParser(data).parseHeader();
    String id = getGifId(data);
    return new GifDataResource(new GifData(context, bitmapPool, id, header, data));
}
项目:AppDevFestSudeste2015    文件:GifResourceDecoder.java   
@Override
public GifDataResource decode(InputStream source, int width, int height) throws IOException {
    byte[] data = inputStreamToBytes(source);
    GifHeader header = new GifHeaderParser(data).parseHeader();
    String id = getGifId(data);
    return new GifDataResource(new GifData(context, bitmapPool, id, header, data));
}
项目:tumblr3d    文件:GifResourceDecoder.java   
public GifTextureResource decode(byte[] data, int width, int height) {
    final GifHeaderParser parser = parserPool.obtain(data);
    final GifDecoder decoder = decoderPool.obtain(provider);
    try {
        return decode(data, width, height, parser, decoder);
    } finally {
        parserPool.release(parser);
        decoderPool.release(decoder);
    }
}
项目:devfestnorte-app    文件:GifResourceDecoder.java   
@Override
public GifDataResource decode(InputStream source, int width, int height) throws IOException {
    byte[] data = inputStreamToBytes(source);
    GifHeader header = new GifHeaderParser(data).parseHeader();
    String id = getGifId(data);
    return new GifDataResource(new GifData(context, bitmapPool, id, header, data));
}
项目:saarang-iosched    文件:GifResourceDecoder.java   
@Override
public GifDataResource decode(InputStream source, int width, int height) throws IOException {
    byte[] data = inputStreamToBytes(source);
    GifHeader header = new GifHeaderParser(data).parseHeader();
    String id = getGifId(data);
    return new GifDataResource(new GifData(context, bitmapPool, id, header, data));
}
项目:GitHub    文件:ReEncodingGifResourceEncoder.java   
public GifHeaderParser buildParser() {
  return new GifHeaderParser();
}
项目:GitHub    文件:ByteBufferGifDecoder.java   
public synchronized void release(GifHeaderParser parser) {
  parser.clear();
  pool.offer(parser);
}
项目:GitHub    文件:ReEncodingGifResourceEncoder.java   
GifHeaderParser buildParser() {
  return new GifHeaderParser();
}
项目:GitHub    文件:ByteBufferGifDecoder.java   
synchronized void release(GifHeaderParser parser) {
  parser.clear();
  pool.offer(parser);
}
项目:tumblr3d    文件:GifResourceDecoder.java   
public synchronized void release(GifHeaderParser parser) {
    parser.clear();
    pool.offer(parser);
}