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

下面列出了怎么用com.bumptech.glide.load.resource.SimpleResource的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: 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);
	}
}
 
源代码2 项目: mollyim-android   文件: BlurHashResourceDecoder.java
@Override
public @Nullable Resource<Bitmap> decode(@NonNull BlurHash source, int width, int height, @NonNull Options options) throws IOException {
  final int finalWidth;
  final int finalHeight;

  if (width > height) {
    finalWidth  = Math.min(width, MAX_DIMEN);
    finalHeight = (int) (finalWidth * height / (float) width);
  } else {
    finalHeight = Math.min(height, MAX_DIMEN);
    finalWidth  = (int) (finalHeight * width / (float) height);
  }

  return new SimpleResource<>(BlurHashDecoder.decode(source.getHash(), finalWidth, finalHeight));
}
 
源代码3 项目: PowerFileExplorer   文件: 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);
    }
}
 
源代码4 项目: PowerFileExplorer   文件: 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);
}
 
源代码5 项目: GlideToVectorYou   文件: SvgDecoder.java
public Resource<SVG> decode(@NonNull InputStream source, int width, int height,
                            @NonNull 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);
  }
}
 
源代码6 项目: GlideToVectorYou   文件: SvgDrawableTranscoder.java
@Nullable
@Override
public Resource<PictureDrawable> transcode(@NonNull Resource<SVG> toTranscode,
                                           @NonNull Options options) {
  SVG svg = toTranscode.get();
  Picture picture = svg.renderToPicture();
  PictureDrawable drawable = new PictureDrawable(picture);
  return new SimpleResource<>(drawable);
}
 
源代码7 项目: 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);
}
 
@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);
}
 
源代码9 项目: 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);
	}
}
 
源代码10 项目: 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;
}
 
源代码11 项目: 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);
    }
}
 
@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);
}
 
源代码13 项目: 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);
}
 
源代码14 项目: glide-support   文件: SimpleResourceDecoder.java
@Override public Resource<T> decode(T source, int width, int height) throws IOException {
	return new SimpleResource<>(source);
}
 
 类所在包
 同包方法