com.bumptech.glide.load.resource.SimpleResource Java Examples
The following examples show how to use
com.bumptech.glide.load.resource.SimpleResource.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PaletteCacheDecoder.java From glide-support with The Unlicense | 6 votes |
@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); } }
Example #2
Source File: BlurHashResourceDecoder.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@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)); }
Example #3
Source File: SvgDecoder.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
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); } }
Example #4
Source File: SvgDrawableTranscoder.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
@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); }
Example #5
Source File: SvgDecoder.java From GlideToVectorYou with Apache License 2.0 | 5 votes |
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); } }
Example #6
Source File: SvgDrawableTranscoder.java From GlideToVectorYou with Apache License 2.0 | 5 votes |
@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); }
Example #7
Source File: BitmapSizeTranscoder.java From glide-support with The Unlicense | 5 votes |
@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); }
Example #8
Source File: OptionsSizeResourceTranscoder.java From glide-support with The Unlicense | 5 votes |
@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); }
Example #9
Source File: PaletteDecoder.java From glide-support with The Unlicense | 5 votes |
@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); } }
Example #10
Source File: PaletteBitmapEncoder.java From glide-support with The Unlicense | 5 votes |
@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; }
Example #11
Source File: SvgDecoder.java From incubator-taverna-mobile with Apache License 2.0 | 5 votes |
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); } }
Example #12
Source File: SvgDrawableTranscoder.java From incubator-taverna-mobile with Apache License 2.0 | 5 votes |
@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); }
Example #13
Source File: BitmapSizeDecoder.java From glide-support with The Unlicense | 4 votes |
@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); }
Example #14
Source File: SimpleResourceDecoder.java From glide-support with The Unlicense | 4 votes |
@Override public Resource<T> decode(T source, int width, int height) throws IOException { return new SimpleResource<>(source); }