类android.graphics.LightingColorFilter源码实例Demo

下面列出了怎么用android.graphics.LightingColorFilter的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: AlbumCameraRecorder   文件: PlayView.java
/**
 * 初始化相关数据
 *
 * @param recordingItem      音频数据源
 * @param audioProgressColor 进度条颜色
 */
public void setData(RecordingItem recordingItem, int audioProgressColor) {
    this.mRecordingItem = recordingItem;
    // 设置进度条颜色
    ColorFilter filter = new LightingColorFilter
            (audioProgressColor, audioProgressColor);
    mViewHolder.seekbar.getProgressDrawable().setColorFilter(filter);
    mViewHolder.seekbar.getThumb().setColorFilter(filter);

    if (!TextUtils.isEmpty(mRecordingItem.getFilePath())) {
        mViewHolder.seekbar.setEnabled(true);
    } else {
        mViewHolder.seekbar.setEnabled(false);
    }

    initData();
}
 
源代码2 项目: APKMirror   文件: MainActivity.java
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void changeUIColor(Integer color) {

    ValueAnimator anim = ValueAnimator.ofArgb(previsionThemeColor, color);
    anim.setEvaluator(new ArgbEvaluator());

    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            progressBar.getProgressDrawable().setColorFilter(new LightingColorFilter(0xFF000000, (Integer) valueAnimator.getAnimatedValue()));
            setSystemBarColor((Integer) valueAnimator.getAnimatedValue());
            navigation.setActiveTabColor((Integer) valueAnimator.getAnimatedValue());
            fabSearch.setBackgroundTintList(ColorStateList.valueOf((Integer) valueAnimator.getAnimatedValue()));

        }
    });

    anim.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
    anim.start();
    refreshLayout.setColorSchemeColors(color, color, color);

}
 
public Bitmap captureView(View view) {
    //Find the view we are after
    //Create a Bitmap with the same dimensions
    Bitmap image = Bitmap.createBitmap(view.getMeasuredWidth(),
            view.getMeasuredHeight(),
            Bitmap.Config.ARGB_4444); //reduce quality and remove opacity
    //Draw the view inside the Bitmap
    Canvas canvas = new Canvas(image);
    view.draw(canvas);

    //Make it frosty
    Paint paint = new Paint();
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    ColorFilter filter = new LightingColorFilter(0xFFFFFFFF, 0x00222222); // lighten
    //ColorFilter filter = new LightingColorFilter(0xFF7F7F7F, 0x00000000);    // darken
    paint.setColorFilter(filter);
    canvas.drawBitmap(image, 0, 0, paint);

    return image;
}
 
public Bitmap captureView(View view) {
  if (mBlurredBitmap != null) {
    return mBlurredBitmap;
  }
  //Find the view we are after
  //Create a Bitmap with the same dimensions
  mBlurredBitmap = Bitmap.createBitmap(view.getMeasuredWidth(),
      view.getMeasuredHeight(),
      Bitmap.Config.ARGB_4444); //reduce quality and remove opacity
  //Draw the view inside the Bitmap
  Canvas canvas = new Canvas(mBlurredBitmap);
  view.draw(canvas);

  //blur it
  ImageHelper.blurBitmapWithRenderscript(rs, mBlurredBitmap);

  //Make it frosty
  Paint paint = new Paint();
  paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
  ColorFilter filter = new LightingColorFilter(0xFFFFFFFF, 0x00222222); // lighten
  //ColorFilter filter = new LightingColorFilter(0xFF7F7F7F, 0x00000000);    // darken
  paint.setColorFilter(filter);
  canvas.drawBitmap(mBlurredBitmap, 0, 0, paint);

  return mBlurredBitmap;
}
 
源代码5 项目: BubbleCloudView   文件: MyListView.java
/**
 * Calculates the lighting of the item based on rotation.
 * 
 * @param rotation The rotation of the item
 * @return A color filter to use
 */
private LightingColorFilter calculateLight(final float rotation) {
    final double cosRotation = Math.cos(Math.PI * rotation / 180);
    int intensity = AMBIENT_LIGHT + (int)(DIFFUSE_LIGHT * cosRotation);
    int highlightIntensity = (int)(SPECULAR_LIGHT * Math.pow(cosRotation, SHININESS));

    if (intensity > MAX_INTENSITY) {
        intensity = MAX_INTENSITY;
    }
    if (highlightIntensity > MAX_INTENSITY) {
        highlightIntensity = MAX_INTENSITY;
    }

    final int light = Color.rgb(intensity, intensity, intensity);
    final int highlight = Color.rgb(highlightIntensity, highlightIntensity, highlightIntensity);

    return new LightingColorFilter(light, highlight);
}
 
源代码6 项目: Effects-Pro   文件: BitmapProcessing.java
public static Bitmap tint(Bitmap src, int color) {
	// image size
	int width = src.getWidth();
	int height = src.getHeight();
	// create output bitmap

	// create a mutable empty bitmap
	Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig());

	Paint p = new Paint(Color.RED);
	ColorFilter filter = new LightingColorFilter(color, 1);
	p.setColorFilter(filter);

	Canvas c = new Canvas();
	c.setBitmap(bmOut);		
	c.drawBitmap(src, 0, 0, p);

	src.recycle();
	src = null;

	return bmOut;
}
 
private void createBitmap(Bitmap quarter) {
  bitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);
  Canvas canvas = new Canvas(bitmap);

  Paint paint = new Paint();

  // Top left
  paint.setColorFilter(new LightingColorFilter(Color.RED, 0));
  canvas.drawBitmap(quarter, 0, 0, paint);

  // Top right
  paint.setColorFilter(new LightingColorFilter(Color.YELLOW, 0));
  canvas.drawBitmap(quarter, getWidth() / 2, 0, paint);

  // Bottom left
  paint.setColorFilter(new LightingColorFilter(Color.BLUE, 0));
  canvas.drawBitmap(quarter, 0, getHeight()/2, paint);

  // Bottom right
  paint.setColorFilter(new LightingColorFilter(Color.GREEN, 0));
  canvas.drawBitmap(quarter, getWidth() / 2, getHeight() / 2, paint);
}
 
源代码8 项目: soas   文件: PhotoView.java
/**
 * Generate label background and foreground colors using Palette base on downloaded image colors.
 *
 * @param bitmap Download bitmap.
 */
@Override
public void onBitmapChange(Bitmap bitmap) {
    if (bitmap == null) { return; }

    Palette.generateAsync(bitmap, new Palette.PaletteAsyncListener() {
        @SuppressWarnings("deprecation")
        public void onGenerated(Palette palette) {
            Resources res = getResources();
            int photoNameColorBg = palette.getDarkMutedColor(res.getColor(R.color.list_item_photo_name_bg));
            int photoNameColorFg = palette.getLightMutedColor(res.getColor(R.color.view_photo_name_fg));

            ColorFilter photoNameColorFilter = new LightingColorFilter(photoNameColorBg, 1);
            Drawable photoNameDrawableBg = res.getDrawable(R.drawable.view_photo_name_bg);
            photoNameDrawableBg.setColorFilter(photoNameColorFilter);
            mPhotoName.setBackgroundDrawable(photoNameDrawableBg);

            mPhotoName.setTextColor(photoNameColorFg);
        }
    });
}
 
源代码9 项目: codeexamples-android   文件: ListView3d.java
private LightingColorFilter calculateLight(final float rotation) {
	final double cosRotation = Math.cos(Math.PI * rotation / 180);
	int intensity = AMBIENT_LIGHT + (int) (DIFFUSE_LIGHT * cosRotation);
	int highlightIntensity = (int) (SPECULAR_LIGHT * Math.pow(cosRotation,
			SHININESS));
	if (intensity > MAX_INTENSITY) {
		intensity = MAX_INTENSITY;
	}
	if (highlightIntensity > MAX_INTENSITY) {
		highlightIntensity = MAX_INTENSITY;
	}
	final int light = Color.rgb(intensity, intensity, intensity);
	final int highlight = Color.rgb(highlightIntensity, highlightIntensity,
			highlightIntensity);
	return new LightingColorFilter(light, highlight);
}
 
源代码10 项目: codeexamples-android   文件: ListView3d.java
private LightingColorFilter calculateLight(final float rotation) {
	final double cosRotation = Math.cos(Math.PI * rotation / 180);
	int intensity = AMBIENT_LIGHT + (int) (DIFFUSE_LIGHT * cosRotation);
	int highlightIntensity = (int) (SPECULAR_LIGHT * Math.pow(cosRotation,
			SHININESS));
	if (intensity > MAX_INTENSITY) {
		intensity = MAX_INTENSITY;
	}
	if (highlightIntensity > MAX_INTENSITY) {
		highlightIntensity = MAX_INTENSITY;
	}
	final int light = Color.rgb(intensity, intensity, intensity);
	final int highlight = Color.rgb(highlightIntensity, highlightIntensity,
			highlightIntensity);
	return new LightingColorFilter(light, highlight);
}
 
@Override
public void process(Bitmap dst, Bitmap src) {
  super.process(dst, src);

  final Canvas canvas = new Canvas(dst);
  final Paint paint = new Paint();

  paint.setColorFilter(new LightingColorFilter(mMul, mAdd));

  canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
  canvas.drawBitmap(src, 0, 0, paint);
}
 
源代码12 项目: WavesView   文件: DoubleWavesShaderView.java
public Wave(View v, Bitmap b, int durationMillis, int color) {
    bitmap = b;
    shader = new BitmapShader(bitmap, Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
    paint = new Paint();
    paint.setShader(shader);
    paint.setAntiAlias(true);
    matrix = new Matrix();
    durMillis = durationMillis;
    viewRef = new WeakReference<>(v);
    if (color != 0) {
        paint.setColorFilter(new LightingColorFilter(0X02FFFFFF, color));
    }
}
 
源代码13 项目: Muzesto   文件: Timber4.java
private Bitmap changeBitmapColor(Bitmap sourceBitmap, int color) {

        Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap, 0, 0,
                sourceBitmap.getWidth() - 1, sourceBitmap.getHeight() - 1);
        Paint p = new Paint();
        ColorFilter filter = new LightingColorFilter(color, 1);
        p.setColorFilter(filter);
        Canvas canvas = new Canvas(resultBitmap);
        canvas.drawBitmap(resultBitmap, 0, 0, p);
        return resultBitmap;
    }
 
源代码14 项目: FrostyBackgroundTestApp   文件: ImageHelper.java
public static Bitmap getRoundedCornerAndLightenBitmap(Bitmap bitmap, int cornerRadiusInPixels, boolean captureCircle) {
    Bitmap output = Bitmap.createBitmap(
            bitmap.getWidth(),
            bitmap.getHeight(),
            Bitmap.Config.ARGB_4444);
    Canvas canvas = new Canvas(output);

    final int color = 0xffffffff;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0,
            0,
            bitmap.getWidth(),
            bitmap.getHeight());
    final RectF rectF = new RectF(rect);
    final float roundPx = cornerRadiusInPixels;

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    if (captureCircle) {
        canvas.drawCircle(rectF.centerX(),
                rectF.centerY(),
                bitmap.getWidth() / 2,
                paint);
    } else {
        canvas.drawRoundRect(rectF,
                roundPx,
                roundPx,
                paint);
    }

    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    ColorFilter filter = new LightingColorFilter(0xFFFFFFFF, 0x00222222); // lighten
    //ColorFilter filter = new LightingColorFilter(0xFF7F7F7F, 0x00000000);    // darken
    paint.setColorFilter(filter);
    canvas.drawBitmap(bitmap, rect, rect, paint);

    return output;
}
 
源代码15 项目: KA27   文件: RecyclerViewFragment.java
public void setProgressBar(ProgressBar progressBar) {
    progressBar.getIndeterminateDrawable().setColorFilter(new LightingColorFilter(0xFF000000,
        ContextCompat.getColor(getActivity(), android.R.color.white)));
    ActionBar actionBar;
    if ((actionBar = getActionBar()) != null) {
        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM);
        actionBar.setCustomView(progressBar, new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.END));
    }
}
 
源代码16 项目: AndroidStudyDemo   文件: StarRatingView.java
private void init() {
	starBitmap = BitmapFactory.decodeResource(getContext().getResources(), R.mipmap.star);
	
	goldPaint = new Paint();
	goldPaint.setFilterBitmap(true);
	
	grayPaint = new Paint();
	grayPaint.setColorFilter(new LightingColorFilter(0xff111122, 0xffcccccc));
	grayPaint.setFilterBitmap(true);
	
	setModel(new StarRatingModel());
}
 
源代码17 项目: droidddle   文件: TintedBitmapDrawable.java
@Override
public void draw(final Canvas canvas) {
    final Paint paint = getPaint();
    if (paint.getColorFilter() == null) {
        paint.setColorFilter(new LightingColorFilter(tint, 0));
        paint.setAlpha(alpha);
    }
    super.draw(canvas);
}
 
源代码18 项目: kernel_adiutor   文件: RecyclerViewFragment.java
public void setProgressBar(ProgressBar progressBar) {
    progressBar.getIndeterminateDrawable().setColorFilter(new LightingColorFilter(0xFF000000,
            getResources().getColor(android.R.color.white)));
    ActionBar actionBar;
    if ((actionBar = getActionBar()) != null) {
        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM);
        actionBar.setCustomView(progressBar, new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
                ActionBar.LayoutParams.WRAP_CONTENT, Gravity.CENTER_VERTICAL | Gravity.END));
    }
}
 
源代码19 项目: PracticeDemo   文件: BitmapUtils.java
/**
 * 给bitmap着色
 * @param sourceBitmap
 * @param color  rgb
 * @return
 */
public static Bitmap changeBitmapColor(@NonNull Bitmap sourceBitmap, @IntegerRes int color) {

    Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap, 0, 0,
            sourceBitmap.getWidth() - 1, sourceBitmap.getHeight() - 1);
    Paint p = new Paint();
    ColorFilter filter = new LightingColorFilter(color, 1);
    p.setColorFilter(filter);

    Canvas canvas = new Canvas(resultBitmap);
    canvas.drawBitmap(resultBitmap, 0, 0, p);
    return resultBitmap;
}
 
源代码20 项目: KUAS-AP-Material   文件: Utils.java
/**
 * White colors can be transformed in to different colors.
 *
 * @param sourceBitmap The source Bitmap
 * @param color        The different color
 * @return The different color Bitmap
 */
public static Bitmap changeImageColor(Bitmap sourceBitmap, int color) {
	Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap, 0, 0, sourceBitmap.getWidth() - 1,
			sourceBitmap.getHeight() - 1);
	Paint p = new Paint();
	ColorFilter filter = new LightingColorFilter(color, 1);
	p.setColorFilter(filter);

	Canvas canvas = new Canvas(resultBitmap);
	canvas.drawBitmap(resultBitmap, 0, 0, p);
	return resultBitmap;
}
 
源代码21 项目: KUAS-AP-Material   文件: Utils.java
/**
 * White colors can be transformed in to different colors.
 *
 * @param sourceBitmap The source Bitmap
 * @param color        The different color
 * @return The different color Bitmap
 */
public static Bitmap changeImageColor(Bitmap sourceBitmap, int color) {
	Bitmap resultBitmap = Bitmap.createBitmap(sourceBitmap, 0, 0, sourceBitmap.getWidth() - 1,
			sourceBitmap.getHeight() - 1);
	Paint p = new Paint();
	ColorFilter filter = new LightingColorFilter(color, 1);
	p.setColorFilter(filter);

	Canvas canvas = new Canvas(resultBitmap);
	canvas.drawBitmap(resultBitmap, 0, 0, p);
	return resultBitmap;
}
 
源代码22 项目: Noyze   文件: BackgroundLinearLayout.java
public void setCustomBackground(Drawable d) {
    mCustomBackground = d;
    if (d != null && d instanceof BitmapDrawable) {
        // This is to add a tint of the background color to the image.
        // It prevents overly exposed or bright backgrounds from ruining the ambiance.
        BitmapDrawable bd = (BitmapDrawable) d;
        bd.getPaint().setColor(backgroundColor);
        ColorFilter filter = new LightingColorFilter(backgroundColor, 1);
        bd.setColorFilter(filter);
    }
    setBackground(mBackgroundDrawable);
    computeCustomBackgroundBounds();
    invalidate();
}
 
源代码23 项目: SuntimesWidget   文件: SuntimesUtils.java
/**
 * Creates a tinted copy of the supplied bitmap.
 * @param b a bitmap image
 * @param color a color
 * @return a bitmap tinted to color
 */
public static Bitmap tintBitmap(Bitmap b, int color)
{
    Bitmap tinted = Bitmap.createBitmap(b.getWidth(), b.getHeight(), b.getConfig());
    Canvas c = new Canvas(tinted);
    Paint p = new Paint();
    p.setColorFilter(new LightingColorFilter(color, 0));
    c.drawBitmap(b, 0, 0, p);
    return tinted;
}
 
源代码24 项目: ChatMessageView   文件: TintedBitmapDrawable.java
@Override
public void draw(final Canvas canvas) {
    final Paint paint = getPaint();
    if (paint.getColorFilter() == null) {
        paint.setColorFilter(new LightingColorFilter(tint, 0));
        paint.setAlpha(alpha);
    }
    super.draw(canvas);
}
 
源代码25 项目: AndroidDemo   文件: LightingColorFilterView.java
public LightingColorFilterView(Context context, AttributeSet attrs) {
    super(context, attrs);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setColorFilter(new LightingColorFilter(0xFFFFFFFF, 0x00FF00FF));
    bitmap = BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher);

}
 
源代码26 项目: AnimatedCircleLoadingView   文件: FinishedView.java
private void drawCheckedMark(Canvas canvas) {
  Paint paint = new Paint();
  paint.setColorFilter(new LightingColorFilter(getDrawableTintColor(), 0));

  Bitmap bitmap = Bitmap.createScaledBitmap(originalFinishedBitmap, imageSize, imageSize, true);
  canvas.drawBitmap(bitmap, parentCenter - bitmap.getWidth() / 2,
      parentCenter - bitmap.getHeight() / 2, paint);
}
 
源代码27 项目: bither-android   文件: UnitUtilWrapper.java
public static Bitmap changeBitmapColor(Bitmap bmp, int color) {
    Bitmap result = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), bmp.getConfig());
    Canvas c = new Canvas(result);
    Paint paint = new Paint();
    ColorFilter filter = new LightingColorFilter(color, 1);
    paint.setColorFilter(filter);
    c.drawBitmap(bmp, 0, 0, paint);
    return result;
}
 
源代码28 项目: tickmate   文件: TickColor.java
public static Drawable getTickedButtonDrawable(Context context, int tickButtonColor) {
    // Prepare the layers & color filter for the LayerDrawable
    ColorFilter cf = new LightingColorFilter(tickButtonColor, 0);
    //ColorDrawable buttonCenterDrawable = new ColorDrawable(0xFF000000 + tickButtonColor);
    Drawable buttonCenterDrawable = ContextCompat.getDrawable(context, R.drawable.mask_64);
    Drawable buttonBorderDrawable = ContextCompat.getDrawable(context, R.drawable.on_64);
    buttonCenterDrawable.setColorFilter(cf);
    sTickedButton = new LayerDrawable(new Drawable[]{buttonCenterDrawable, buttonBorderDrawable});
    return sTickedButton;
}
 
源代码29 项目: NotificationPeekPort   文件: NotificationHelper.java
public static View.OnTouchListener getHighlightTouchListener(final int color) {
    return new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent event) {
            Drawable drawable = ((ImageView) view).getDrawable();
            switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    LightingColorFilter lighten = new LightingColorFilter(color, color);
                    drawable.setColorFilter(lighten);
                    break;
                case MotionEvent.ACTION_UP:
                    drawable.clearColorFilter();
                    break;
                case MotionEvent.ACTION_MOVE:
                    Rect rect = new Rect();
                    view.getLocalVisibleRect(rect);
                    if (!rect.contains((int) event.getX(), (int) event.getY())) {
                        drawable.clearColorFilter();
                    }
                    break;
                case MotionEvent.ACTION_OUTSIDE:
                case MotionEvent.ACTION_CANCEL:
                    drawable.clearColorFilter();
                    break;
            }
            return false;
        }
    };
}
 
源代码30 项目: Noyze   文件: BackgroundLinearLayout.java
public void setCustomBackground(Drawable d) {
    mCustomBackground = d;
    if (d != null && d instanceof BitmapDrawable) {
        // This is to add a tint of the background color to the image.
        // It prevents overly exposed or bright backgrounds from ruining the ambiance.
        BitmapDrawable bd = (BitmapDrawable) d;
        bd.getPaint().setColor(backgroundColor);
        ColorFilter filter = new LightingColorFilter(backgroundColor, 1);
        bd.setColorFilter(filter);
    }
    setBackground(mBackgroundDrawable);
    computeCustomBackgroundBounds();
    invalidate();
}
 
 类所在包
 类方法
 同包方法