Java 类android.graphics.ColorFilter 实例源码

项目:Xndroid    文件:ThemeUtils.java   
/**
 * Gets the icon with an applied color filter
 * for the correct theme.
 *
 * @param context the context to use.
 * @param res     the drawable resource to use.
 * @param dark    true for icon suitable for use with a dark theme,
 *                false for icon suitable for use with a light theme.
 * @return a themed icon.
 */
@NonNull
public static Bitmap getThemedBitmap(@NonNull Context context, @DrawableRes int res, boolean dark) {
    int color = dark ? getIconDarkThemeColor(context) : getIconLightThemeColor(context);

    Bitmap sourceBitmap = getBitmapFromVectorDrawable(context, res);
    Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap.getWidth(), sourceBitmap.getHeight(),
        Bitmap.Config.ARGB_8888);
    Paint p = new Paint();
    ColorFilter filter = new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN);
    p.setColorFilter(filter);
    Canvas canvas = new Canvas(resultBitmap);
    canvas.drawBitmap(sourceBitmap, 0, 0, p);
    sourceBitmap.recycle();
    return resultBitmap;
}
项目:Hello-Music-droid    文件:FolderAdapter.java   
public void applyTheme(boolean dark) {
    ColorFilter cf = new PorterDuffColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP);
    for (Drawable d : mIcons) {
        if (dark) {
            d.setColorFilter(cf);
        } else {
            d.clearColorFilter();
        }
    }
}
项目:FastAndroid    文件:CircleImageView.java   
@Override
public void setColorFilter(ColorFilter cf) {
    if (cf == mColorFilter) {
        return;
    }

    mColorFilter = cf;
    applyColorFilter();
    invalidate();
}
项目:MusicX-music-player    文件:CircleImageView.java   
@Override
public void setColorFilter(ColorFilter cf) {
    if (cf == mColorFilter) {
        return;
    }

    mColorFilter = cf;
    applyColorFilter();
    invalidate();
}
项目:ChinaMapInfoView    文件:CnSvgBigRenderer.java   
private void renderGo(Canvas canvas, ColorFilter filter, Paint paint, int i) {
    if (i >= 0 && i <= 8) {
        renderByProvince1(i);
    } else if (i >= 9 && i <= 19) {
        renderByProvince2(i);
    } else if (i >= 20 && i <= 29) {
        renderByProvince3(i);
    } else if (i >= 29 && i <= 33) {
        renderByProvince4(i);
    }
    mRenderPath.addPath(mPath, mFinalPathMatrix);
    paint.setStrokeJoin(Paint.Join.MITER);
    paint.setStrokeCap(Paint.Cap.BUTT);
    paint.setStrokeMiter(4.0f);
    paint.setColorFilter(filter);
    canvas.drawPath(mRenderPath, paint);

    // Region
    mRegion = mRegionList.get(i);
    mRegion.setPath(mRenderPath, mGlobalRegion);
    mRegionList.set(i, mRegion);

    mPath.reset();
    mRenderPath.reset();

    mFinalPathMatrix.setValues(
            new float[]{1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}
    );
    mFinalPathMatrix.postScale(scaleX, scaleY);
}
项目:boohee_v5.6    文件:AnimatedVectorDrawableCompat.java   
public void setColorFilter(ColorFilter colorFilter) {
    if (this.mDelegateDrawable != null) {
        this.mDelegateDrawable.setColorFilter(colorFilter);
    } else {
        this.mAnimatedVectorState.mVectorDrawable.setColorFilter(colorFilter);
    }
}
项目:chromium-net-for-android    文件:ApiCompatibilityUtils.java   
/**
 * @see android.graphics.drawable.Drawable#getColorFilter().
 */
@SuppressWarnings("NewApi")
public static ColorFilter getColorFilter(Drawable drawable) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return drawable.getColorFilter();
    } else {
        return null;
    }
}
项目:GitHub    文件:AnimationBackendDelegate.java   
@Override
public void setColorFilter(ColorFilter colorFilter) {
  if (mAnimationBackend != null) {
    mAnimationBackend.setColorFilter(colorFilter);
  }
  mColorFilter = colorFilter;
}
项目:RotateCircleImageView    文件:RotateCircleImageView.java   
@Override
public void setColorFilter(ColorFilter cf) {
    if (cf == mColorFilter) {
        return;
    }
    mColorFilter = cf;
    applyColorFilter();
    invalidate();
}
项目:GitHub    文件:DrawableUtilsTest.java   
@Test
public void testSetDrawablePropertiesDefault() {
  DrawableProperties properties = new DrawableProperties();
  Drawable drawableTo = mock(Drawable.class);
  DrawableUtils.setDrawableProperties(drawableTo, properties);
  verify(drawableTo, never()).setAlpha(anyInt());
  verify(drawableTo, never()).setColorFilter(any(ColorFilter.class));
  verify(drawableTo, never()).setDither(anyBoolean());
  verify(drawableTo, never()).setFilterBitmap(anyBoolean());
}
项目:Alerter    文件:Alerter.java   
/**
 * Set the icon color for the Alert
 *
 * @param colorFilter ColorFilter
 * @return This Alerter
 */
public Alerter setIconColorFilter(@NonNull final ColorFilter colorFilter) {
    if (getAlert() != null) {
        getAlert().setIconColorFilter(colorFilter);
    }

    return this;
}
项目:Widgets    文件:AbsCornerImageView.java   
@Override
public void setColorFilter(ColorFilter cf) {
    if (cf == mColorFilter) {
        return;
    }

    mColorFilter = cf;
    applyColorFilter();
    invalidate();
}
项目:AndroidSkinAnimator    文件:CircleImageView.java   
@Override
public void setColorFilter(ColorFilter cf) {
    if (cf == mColorFilter) {
        return;
    }

    mColorFilter = cf;
    applyColorFilter();
    invalidate();
}
项目:revolution-irc    文件:DrawableWrapper.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public ColorFilter getColorFilter() {
    return mDrawable.getColorFilter();
}
项目:ucar-weex-core    文件:MaterialProgressDrawable.java   
@Override
public void setColorFilter(ColorFilter colorFilter) {
  mRing.setColorFilter(colorFilter);
}
项目:SmartRefreshLayout    文件:MaterialProgressDrawable.java   
public void setColorFilter(ColorFilter filter) {
    mPaint.setColorFilter(filter);
    invalidateSelf();
}
项目:SliderPreferenceEmbedded    文件:StateDrawable.java   
@Override
public void setColorFilter(ColorFilter cf) {
    mPaint.setColorFilter(cf);
}
项目:Hitalk    文件:RoundRectDrawableWithShadow.java   
@Override
public void setColorFilter(ColorFilter cf) {
    mPaint.setColorFilter(cf);
    mCornerShadowPaint.setColorFilter(cf);
    mEdgeShadowPaint.setColorFilter(cf);
}
项目:iosched-reader    文件:SVGBuilder.java   
/**
 * Applies a {@link ColorFilter} to the paint objects used to render the SVG.
 */
public SVGBuilder setColorFilter(ColorFilter colorFilter) {
    this.strokeColorFilter = this.fillColorFilter = colorFilter;
    return this;
}
项目:Nird2    文件:EmojiProvider.java   
@Override
public void setColorFilter(@Nullable ColorFilter cf) {
}
项目:jackknife    文件:RoundDrawable.java   
@Override
public void setColorFilter(ColorFilter cf) {
    mPaint.setColorFilter(cf);
}
项目:shareNote    文件:RoundedDrawable.java   
@Override
public ColorFilter getColorFilter() {
  return mBitmapPaint.getColorFilter();
}
项目:GitHub    文件:CollisionLoadingRenderer.java   
@Override
protected void setColorFilter(ColorFilter cf) {
    mPaint.setColorFilter(cf);
}
项目:qmui    文件:QMUIViewHelper.java   
public static ColorFilter setImageViewTintColor(ImageView imageView, @ColorInt int tintColor) {
    LightingColorFilter colorFilter = new LightingColorFilter(Color.argb(255, 0, 0, 0), tintColor);
    imageView.setColorFilter(colorFilter);
    return colorFilter;
}
项目:android_ui    文件:ProgressDrawable.java   
/**
 */
@Override
public void setColorFilter(ColorFilter colorFilter) {
    PAINT.setColorFilter(colorFilter);
}
项目:ucar-weex-core    文件:BorderDrawable.java   
/**
 * Do not support Color Filter
 */
@Override
public void setColorFilter(ColorFilter cf) {

}
项目:DreamDrawable    文件:LauncherIconDrawable.java   
@Override
public void setColorFilter(ColorFilter cf) {
    if (mDrawable != null) {
        mDrawable.setColorFilter(cf);
    }
}
项目:style-transfer    文件:Region.java   
public Drawable findMatch(ScriptC_find_region findRegion, RenderScript mRs, Bitmap image) {
    Rect mRoiBounds = mFindRegion.findMatch(findRegion, mRs, image);
    int cutOffsetX = mFindRegion.getCutOffsetX();
    int cutOffsetY = mFindRegion.getCutOffsetY();
    final Path path = new Path();
    for (int i = 0; i < mPointsXY.length; i += 2) {
        if (i == 0) {
            path.moveTo(mPointsXY[i] - mRoiBounds.left + cutOffsetX,
                    mPointsXY[i + 1] - mRoiBounds.top + cutOffsetY);
        } else {
            path.lineTo(mPointsXY[i] - mRoiBounds.left + cutOffsetX,
                    mPointsXY[i + 1] - mRoiBounds.top + cutOffsetY);
        }
    }

    path.close();


    Drawable d = new Drawable() {
        Paint paint = new Paint();

        {
            paint.setStyle(Paint.Style.STROKE);
        }

        @Override
        public void draw(Canvas canvas) {
            canvas.drawPath(path, paint);
        }

        @Override
        public void setAlpha(int alpha) {
        }

        @Override
        public void setColorFilter(ColorFilter cf) {
        }

        @Override
        public int getOpacity() {
            return 0;
        }
    };
    return d;
}
项目:shareNote    文件:RoundedDrawable.java   
@Override
public void setColorFilter(ColorFilter cf) {
  mBitmapPaint.setColorFilter(cf);
  invalidateSelf();
}
项目:GitHub    文件:CoolWaitLoadingRenderer.java   
@Override
protected void setColorFilter(ColorFilter cf) {
    mPaint.setColorFilter(cf);

}
项目:snippety    文件:LineDrawable.java   
@Override public void setColorFilter(ColorFilter colorFilter) {
    paint.setColorFilter(colorFilter);
}
项目:GitHub    文件:BalloonLoadingRenderer.java   
@Override
protected void setColorFilter(ColorFilter cf) {
    mPaint.setColorFilter(cf);
}
项目:LoginConcept    文件:TextSizeTransition.java   
@Override
public void setColorFilter(ColorFilter colorFilter) {
    paint.setColorFilter(colorFilter);
}
项目:CanvasScript    文件:PaintScript.java   
public PaintScript colorFilter(@Nullable ColorFilter filter) {
    paint.setColorFilter(filter);
    return this;
}
项目:boohee_v5.6    文件:RoundedDrawable.java   
public ColorFilter getColorFilter() {
    return this.mBitmapPaint.getColorFilter();
}
项目:boohee_v5.6    文件:DrawableCompat.java   
public static ColorFilter getColorFilter(Drawable drawable) {
    return IMPL.getColorFilter(drawable);
}
项目:weex-3d-map    文件:MaterialProgressDrawable.java   
@Override
public void setColorFilter(ColorFilter colorFilter) {
  mRing.setColorFilter(colorFilter);
}
项目:MaterialOCR    文件:FastBitmapDrawable.java   
@Override
public void setColorFilter(ColorFilter cf) {
    mPaint.setColorFilter(cf);
}
项目:AndroidUiKit    文件:MaterialProgressDrawable.java   
public void setColorFilter(ColorFilter filter) {
    mPaint.setColorFilter(filter);
    invalidateSelf();
}
项目:MyLoadingViews    文件:RightDrawable.java   
@Override
public void setColorFilter(@Nullable ColorFilter colorFilter) {
    mPaint.setColorFilter(colorFilter);
}