# GifSamplerForGlide **Repository Path**: papillonyang/GifSamplerForGlide ## Basic Information - **Project Name**: GifSamplerForGlide - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-10-16 - **Last Updated**: 2020-12-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 参看文章 https://juejin.im/post/5f1d4470e51d45348e27c24b # 效果 ![](https://i.loli.net/2020/08/01/uki5CJYLBmOq14R.gif) # Feature 支持圆形GIF加载 配置可查看GifResourceDecoder.java FrameSequenceDrawable.java ```java @Override public GifDrawableResource decode(@NonNull InputStream source, int width, int height, @NonNull Options options) throws IOException { GifDecoder decoder = GifDecoder.decodeStream(source); if (decoder == null) { return null; } int inSampleSize = calcSampleSize(decoder.getWidth(), decoder.getHeight(), width, height); FrameSequenceDrawable drawable = new FrameSequenceDrawable(decoder, mProvider, inSampleSize); // 圆形Gif显示开关 drawable.setCircleMaskEnabled(false); return new GifDrawableResource(drawable); } ``` ```java /** * Pass true to mask the shape of the animated drawing content to a circle. * *

The masking circle will be the largest circle contained in the Drawable's bounds. * Masking is done with BitmapShader, incurring minimal additional draw cost. */ public final void setCircleMaskEnabled(boolean circleMaskEnabled) { if (mCircleMaskEnabled != circleMaskEnabled) { mCircleMaskEnabled = circleMaskEnabled; // Anti alias only necessary when using circular mask mPaint.setAntiAlias(circleMaskEnabled); invalidateSelf(); } } ```