Java 类com.bumptech.glide.load.resource.SimpleResource 实例源码

项目:glide-support    文件:PaletteCacheDecoder.java   
@Override public Resource<Palette> decode(InputStream source, int width, int height) throws IOException {
    if (!source.markSupported()) {
        source = new BufferedInputStream(source);
    }
    Log.d("PALETTE", "Decoding from cache");
    if (isBitmap(source)) {
        Log.d("PALETTE", "It's a cached bitmap");
        Resource<Bitmap> bitmap = bitmapDecoder.decode(source, width, height);
        try {
            Palette palette = new Palette.Builder(bitmap.get())
                    .resizeBitmapArea(-1)
                    .generate();
            Log.d("PALETTE", "Palette generated");
            return new SimpleResource<>(palette);
        } finally {
            bitmap.recycle();
        }
    } else {
        Log.d("PALETTE", "It's a cached palette");
        if (PaletteCacheEncoder.PALETTE_MAGIC_BYTE != source.read()) {
            throw new IOException("Cannot read palette magic.");
        }
        return paletteDecoder.decode(source, width, height);
    }
}
项目:GitHub    文件:SvgDecoder.java   
public Resource<SVG> decode(InputStream source, int width, int height, Options options)
    throws IOException {
  try {
    SVG svg = SVG.getFromInputStream(source);
    return new SimpleResource<SVG>(svg);
  } catch (SVGParseException ex) {
    throw new IOException("Cannot load SVG from stream", ex);
  }
}
项目:GitHub    文件:SvgDrawableTranscoder.java   
@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode) {
  SVG svg = toTranscode.get();
  Picture picture = svg.renderToPicture();
  PictureDrawable drawable = new PictureDrawable(picture);
  return new SimpleResource<PictureDrawable>(drawable);
}
项目:GitHub    文件:SvgDecoder.java   
public Resource<SVG> decode(InputStream source, int width, int height, Options options)
    throws IOException {
  try {
    SVG svg = SVG.getFromInputStream(source);
    return new SimpleResource<>(svg);
  } catch (SVGParseException ex) {
    throw new IOException("Cannot load SVG from stream", ex);
  }
}
项目:GitHub    文件:SvgDrawableTranscoder.java   
@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode, Options options) {
  SVG svg = toTranscode.get();
  Picture picture = svg.renderToPicture();
  PictureDrawable drawable = new PictureDrawable(picture);
  return new SimpleResource<>(drawable);
}
项目:udacity-p3    文件:SvgDecoder.java   
public Resource<SVG> decode(InputStream source, int width, int height) throws IOException {
    try {
        SVG svg = SVG.getFromInputStream(source);
        return new SimpleResource<SVG>(svg);
    } catch (SVGParseException ex) {
        throw new IOException("Cannot load SVG from stream", ex);
    }
}
项目:udacity-p3    文件:SvgDrawableTranscoder.java   
@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode) {
    SVG svg = toTranscode.get();
    Picture picture = svg.renderToPicture();
    PictureDrawable drawable = new PictureDrawable(picture);
    return new SimpleResource<PictureDrawable>(drawable);
}
项目:AndroidBaseApplication    文件:SvgDecoder.java   
@Override
public Resource<SVG> decode (InputStream source, int width, int height) throws IOException
{
    try
    {
        SVG svg = SVG.getFromInputStream( source );
        return new SimpleResource<SVG>( svg );
    } catch ( SVGParseException ex )
    {
        throw new IOException( "Cannot load SVG from stream", ex );
    }
}
项目:AndroidBaseApplication    文件:SvgDrawableTranscoder.java   
@Override
public Resource<PictureDrawable> transcode (Resource<SVG> toTranscode)
{
    SVG svg = toTranscode.get( );
    Picture picture = svg.renderToPicture( );
    PictureDrawable drawable = new PictureDrawable( picture );
    return new SimpleResource<PictureDrawable>( drawable );
}
项目:glide-support    文件:BitmapSizeTranscoder.java   
@Override public Resource<Size> transcode(Resource<Bitmap> toTranscode) {
    Bitmap bitmap = toTranscode.get();
    Size size = new Size();
    size.width = bitmap.getWidth();
    size.height = bitmap.getHeight();
    return new SimpleResource<>(size);
}
项目:glide-support    文件:OptionsSizeResourceTranscoder.java   
@Override public Resource<Size> transcode(Resource<Options> toTranscode) {
    Options options = toTranscode.get();
    Size size = new Size();
    size.width = options.outWidth;
    size.height = options.outHeight;
    return new SimpleResource<>(size);
}
项目:glide-support    文件:PaletteDecoder.java   
@Override public Resource<Palette> decode(InputStream source, int width, int height) throws IOException {
    try {
        ObjectInputStream stream = new ObjectInputStream(source);
        PaletteSerializer palette = (PaletteSerializer)stream.readObject();
        Log.d("PALETTE", "Palette loaded");
        return new SimpleResource<>(palette.getPalette());
    } catch (Exception e) {
        Log.w("PALETTE", "Cannot deserialize", e);
        throw new IOException("Cannot read palette", e);
    }
}
项目:glide-support    文件:PaletteBitmapEncoder.java   
@Override public boolean encode(Resource<PaletteBitmap> data, OutputStream os) {
    PaletteBitmap bitmap = data.get();
    // Resource objects are only created to satisfy the contract, they don't need to be recycled.
    boolean paletteOK = paletteEncoder.encode(new SimpleResource<>(bitmap.palette), os);
    boolean bitmapOK = bitmapEncoder.encode(new BitmapResource(bitmap.bitmap, FAKE_POOL), os);
    return bitmapOK && paletteOK;
}
项目:Gallery    文件:BitmapSizeDecoder.java   
@Override
public Resource<Options> decode(File source, int width, int height) throws
        IOException {
    Options options = new Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(source.getAbsolutePath(), options);
    return new SimpleResource<>(options);
}
项目:stepik-android    文件:SvgDecoder.java   
@Override
public Resource<SVG> decode(InputStream source, int width, int height) throws IOException {
    try {
        SVG svg = SVG.getFromInputStream(source);
        svg.setDocumentHeight(height);
        svg.setDocumentWidth(width);
        svg.setDocumentPreserveAspectRatio(PreserveAspectRatio.LETTERBOX);
        return new SimpleResource<>(svg);
    } catch (SVGParseException ex) {
        throw new IOException("Cannot load SVG from stream", ex);
    }
}
项目:stepik-android    文件:SvgDrawableTranscoder.java   
@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode) {
    SVG svg = toTranscode.get();
    Picture picture = svg.renderToPicture();
    PictureDrawable drawable = new PictureDrawable(picture);
    return new SimpleResource<>(drawable);
}
项目:incubator-taverna-mobile    文件:SvgDecoder.java   
public Resource<SVG> decode(InputStream source, int width, int height) throws IOException {
    try {
        SVG svg = SVG.getFromInputStream(source);
        return new SimpleResource<SVG>(svg);
    } catch (SVGParseException ex) {
        throw new IOException("Cannot load SVG from stream", ex);
    }
}
项目:incubator-taverna-mobile    文件:SvgDrawableTranscoder.java   
@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode) {
    SVG svg = toTranscode.get();
    Picture picture = svg.renderToPicture();
    PictureDrawable drawable = new PictureDrawable(picture);
    return new SimpleResource<PictureDrawable>(drawable);
}
项目:xamoom-android-sdk    文件:SvgDecoder.java   
public Resource<SVG> decode(InputStream source, int width, int height) throws IOException {
    try {
        SVG svg = SVG.getFromInputStream(source);
        return new SimpleResource<>(svg);
    } catch (SVGParseException ex) {
        throw new IOException("Cannot load SVG from stream", ex);
    }
}
项目:xamoom-android-sdk    文件:SvgDrawableTranscoder.java   
@Override
public Resource<PictureDrawable> transcode(Resource<SVG> toTranscode) {
    SVG svg = toTranscode.get();
    Picture picture;
    if (svg.getDocumentWidth() != -1) {
        svg.setDocumentPreserveAspectRatio(PreserveAspectRatio.FULLSCREEN);
        picture = svg.renderToPicture();
    } else {
        picture = svg.renderToPicture(mDeviceWidth, Math.round(mDeviceWidth/svg.getDocumentAspectRatio()));
    }

    PictureDrawable drawable = new PictureDrawable(picture);
    return new SimpleResource<>(drawable);
}
项目:glide-support    文件:BitmapSizeDecoder.java   
@Override public Resource<Options> decode(File source, int width, int height) throws IOException {
    Options options = new Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(source.getAbsolutePath(), options);
    return new SimpleResource<>(options);
}
项目:glide-support    文件:SimpleResourceDecoder.java   
@Override public Resource<T> decode(T source, int width, int height) throws IOException {
    return new SimpleResource<>(source);
}