Java 类android.graphics.LightingColorFilter 实例源码

项目:mobile-store    文件:WifiQrView.java   
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    setUIFromWifi();

    ImageView qrImage = (ImageView) findViewById(R.id.wifi_qr_code);

    // Replace all blacks with the background blue.
    qrImage.setColorFilter(new LightingColorFilter(0xffffffff, getResources().getColor(R.color.swap_blue)));

    Button openQr = (Button) findViewById(R.id.btn_qr_scanner);
    openQr.setOnClickListener(new Button.OnClickListener() {
        @Override
        public void onClick(View v) {
            getActivity().initiateQrScan();
        }
    });

    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(
            onWifiStateChanged, new IntentFilter(WifiStateChangeService.BROADCAST));
}
项目:NoticeDog    文件:OverlayNotificationBarView.java   
private void setButton(Button button, Message message, int index) {
    List<Action> actions = message.getActions();
    if (index >= actions.size()) {
        button.setVisibility(View.GONE);
        return;
    }
    Action action = (Action) actions.get(index);
    button.setOnClickListener(null);
    button.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
    button.setCompoundDrawablesRelativeWithIntrinsicBounds(0, 0, 0, 0);
    button.setVisibility(View.VISIBLE);
    Drawable icon = getActionIcon(message.getAppId(), action.icon);
    icon.setColorFilter(new LightingColorFilter(ViewCompat.MEASURED_STATE_MASK, 6914181));
    button.setCompoundDrawablesRelativeWithIntrinsicBounds(icon, null, null, null);
    button.setText(action.title);
}
项目:Blockly    文件:BlockView.java   
private void initDrawingObjects() {
    int blockColour = mBlock.getColor();
    if (mBlock.isShadow()) {
        float hsv[] = new float[3];
        Color.colorToHSV(blockColour, hsv);
        hsv[1] *= SHADOW_SATURATION_MULTIPLIER;
        hsv[2] *= SHADOW_VALUE_MULTIPLIER;
        if (hsv[2] > 1) {
            hsv[2] = 1;
        }
        blockColour = Color.HSVToColor(hsv);
    }

    // Highlight color channels are added to each color-multiplied color channel, and since the
    // patches are 50% gray, the addition should be 50% of the base value.
    final int highlight = Color.argb(255, Color.red(blockColour) / 2,
            Color.green(blockColour) / 2, Color.blue(blockColour) / 2);
    mBlockColorFilter = new LightingColorFilter(blockColour, highlight);

    mFillPaint.setColor(blockColour);
    mFillPaint.setStyle(Paint.Style.FILL);
}
项目: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);

}
项目:FrostyBackgroundTestApp    文件:ScrollingActivity.java   
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;
}
项目:FrostyBackgroundTestApp    文件:CardViewActivity.java   
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;
}
项目:fdroid    文件:WifiQrView.java   
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    setUIFromWifi();

    ImageView qrImage = (ImageView) findViewById(R.id.wifi_qr_code);

    // Replace all blacks with the background blue.
    qrImage.setColorFilter(new LightingColorFilter(0xffffffff, getResources().getColor(R.color.swap_blue)));

    Button openQr = (Button) findViewById(R.id.btn_qr_scanner);
    openQr.setOnClickListener(new Button.OnClickListener() {
        @Override
        public void onClick(View v) {
            getActivity().initiateQrScan();
        }
    });

    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(
            onWifiStateChanged, new IntentFilter(WifiStateChangeService.BROADCAST));
}
项目:zone-sdk    文件:LightingColorFilterView.java   
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);


    System.out.println("View.isHardwareAccelerated:"+isHardwareAccelerated());
    int width  = 300;
    //这里是为了等比缩放
    int height = width * mBmp.getHeight()/mBmp.getWidth();
    canvas.drawBitmap(mBmp,null,new Rect(0,0,width,height),mPaint);

    //为什么是ff而不能是01呢 因为A默认值是ff 所以 矩阵相乘的时候  会在mod255
    canvas.translate(0,height);
    mPaint.setColorFilter(new LightingColorFilter(0xffffff,0x0000f0));
    canvas.drawBitmap(mBmp,null,new Rect(0,0,width,height),mPaint);

    canvas.translate(0,height);
    mPaint.setColorFilter(new LightingColorFilter(0x00ff00,0x000000));
    canvas.drawBitmap(mBmp,null,new Rect(0,0,width,height),mPaint);
}
项目:AndroidExerciseProgram    文件:LightingColorCustomView.java   
@Override
    public void onClick(View v) {
        if (x >= (appAreaRect.width() - mBitmap.getWidth()) / 2
                && x <= mBitmap.getWidth() + (appAreaRect.width() - mBitmap.getWidth()) / 2
                && y >= (appAreaRect.height() - MeasureUtil.getToolbarHeight(getContext()) - mBitmap.getHeight()) / 2
                && y <= mBitmap.getHeight() + (appAreaRect.height() - MeasureUtil.getToolbarHeight(getContext()) - mBitmap.getHeight()) / 2) {
//        LightingColorFilter(0xFFFFFFFF, 0x00000000)的时候原图是不会有任何改变的,如果我们想增加红色的值,那么LightingColorFilter(0xFFFFFFFF, 0x00XX0000)就好,其中XX取值为00至FF。
//        那么这个方法有什么存在的意义呢?存在必定合理,这个方法存在一定是有它可用之处的,点击一个图片如何直接改变它的颜色而不是为他多准备另一张点击效果的图片
            if (mPaint.getColorFilter() == null) {
                mPaint.setColorFilter(new LightingColorFilter(0xffffffff, 0x00445566));
            } else {
                mPaint.setColorFilter(null);
            }
            invalidate();
        }

    }
项目:shikimori    文件:Blur.java   
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
    private static void blur(Context context, Bitmap bkg, View view) {
        if(bkg==null)
            return;
        long startMs = System.currentTimeMillis();
        float scaleFactor = 8;
        float radius = 2;

        Bitmap overlay = Bitmap.createBitmap((int) (view.getMeasuredWidth()/scaleFactor),
                (int) (view.getMeasuredHeight()/scaleFactor), Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(overlay);
        canvas.translate(-view.getLeft()/scaleFactor, -view.getTop()/scaleFactor);
        canvas.scale(1 / scaleFactor, 1 / scaleFactor);
        Paint paint = new Paint();
        ColorFilter filter = new LightingColorFilter(Color.parseColor("#666666"), 1);
//        paint.setFlags(Paint.FILTER_BITMAP_FLAG);
        paint.setColorFilter(filter);
        canvas.drawBitmap(bkg, 0, 0, paint);

        overlay = FastBlur.doBlur(overlay, (int)radius, true);
        view.setBackground(new BitmapDrawable(context.getResources(), overlay));

        playFade(view);

        Log.d("blur time", "" + (System.currentTimeMillis() - startMs) + "ms");
    }
项目:DeckView    文件:DeckChildViewThumbnail.java   
/**
 * Updates the paint to draw the thumbnail.
 */
void updateThumbnailPaintFilter() {
    if (mInvisible) {
        return;
    }
    int mul = (int) ((1.0f - mDimAlpha) * mThumbnailAlpha * 255);
    int add = (int) ((1.0f - mDimAlpha) * (1 - mThumbnailAlpha) * 255);
    if (mBitmapShader != null) {
        mLightingColorFilter =
                new LightingColorFilter(Color.argb(255, mul, mul, mul),
                        Color.argb(0, add, add, add));
        mDrawPaint.setColorFilter(mLightingColorFilter);
        mDrawPaint.setColor(0xffffffff);
    } else {
        int grey = mul + add;
        mDrawPaint.setColorFilter(null);
        mDrawPaint.setColor(Color.argb(255, grey, grey, grey));
    }
    invalidate();
}
项目: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);
}
项目:AugmentedOxford    文件:DragAndDropListener.java   
private ImageView getImageView(View source, Activity activity,
        RelativeLayout c, LayoutParams params) {
    if (imageView == null) {
        final Bitmap bitmap = IO.loadBitmapFromView(source);
        final Paint shadowPaint = new Paint();
        shadowPaint.setAlpha(180);
        // http://stackoverflow.com/questions/7048941/how-to-use-the-lightingcolorfilter-to-make-the-image-form-dark-to-light
        shadowPaint.setColorFilter(new LightingColorFilter(0x11333333,
                0x00000000));

        imageView = new ImageView(activity) {

            @Override
            protected void onDraw(Canvas canvas) {
                // First draw shadow
                float dist = 2;
                canvas.drawBitmap(bitmap, dist, dist, shadowPaint);
                // then draw normal image view
                super.onDraw(canvas);
            }
        };
        imageView.setImageBitmap(bitmap);
        c.addView(imageView);
    }
    return imageView;
}
项目:SimpleGlowLWP    文件:BlindsView.java   
private LightingColorFilter calculateLight(float rotation) {
    rotation -= LIGHT_SOURCE_ANGLE;
    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);
}
项目:fdroidclient    文件:WifiQrView.java   
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    setUIFromWifi();

    ImageView qrImage = (ImageView) findViewById(R.id.wifi_qr_code);

    // Replace all blacks with the background blue.
    qrImage.setColorFilter(new LightingColorFilter(0xffffffff, getResources().getColor(R.color.swap_blue)));

    Button openQr = (Button) findViewById(R.id.btn_qr_scanner);
    openQr.setOnClickListener(new Button.OnClickListener() {
        @Override
        public void onClick(View v) {
            getActivity().initiateQrScan();
        }
    });

    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(
            onWifiStateChanged, new IntentFilter(WifiStateChangeService.BROADCAST));
}
项目: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;
}
项目:android-graphics-demo    文件:FourColorsImageView.java   
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);
}
项目:schoolapp    文件:WebViewFrag.java   
public void setColors() {
    progressBar2 = (ProgressBarDeterminate)view.findViewById(R.id.progressBar2);
    if (Build.VERSION.SDK_INT >= 21) {
        progressBar = (ProgressBar)view.findViewById(R.id.progressBar1);
        if (Other.getColor2(getActivity(), 1).equals("005400")) {
            progressBar.getIndeterminateDrawable().setColorFilter(new LightingColorFilter(0xFF005400, 0xFF005400));
        } else {
            progressBar.getIndeterminateDrawable().setColorFilter(new LightingColorFilter(0xFF003061, 0xFF003061));
        }
    } else {
        progressBarCompat = (ProgressBarCircularIndeterminate)view.findViewById(R.id.progressBar1);
        progressBarCompat.setBackgroundColor(Color.parseColor("#ff" + Other.getColor2(getActivity(), 1)));
    }
    progressBar2.setBackgroundColor(Color.parseColor("#ff" + Other.getColor2(getActivity(), 1)));
    fabopen.setColorNormal(Color.parseColor("#" + Other.getColor2(getActivity(), 0)));
    fabopen.setColorPressed(Color.parseColor("#" + Other.getColor2(getActivity(), 1)));
    fabdownload.setColorNormal(Color.parseColor("#" + Other.getColor2(getActivity(), 0)));
    fabdownload.setColorPressed(Color.parseColor("#" + Other.getColor2(getActivity(), 1)));
}
项目:schoolapp    文件:MainActivity.java   
public static void setRefreshActionButtonState(final boolean refreshing, Activity activity) {
    if (optionsMenu != null && activity != null) {
        final MenuItem refreshItem = optionsMenu.findItem(R.id.menu_refresh);
        if (refreshItem != null) {
            if (refreshing) {
                LayoutInflater inflatere = activity.getLayoutInflater();
                View v = inflatere.inflate(R.layout.toolbar_progress, null);
                if (Build.VERSION.SDK_INT >= 21) {
                    ProgressBar refresh = (ProgressBar)v.findViewById(R.id.progressBar1);
                    refresh.getIndeterminateDrawable().setColorFilter(new LightingColorFilter(0xFFFFFFFF, 0xFFFFFFFF));
                }
                MenuItemCompat.setActionView(refreshItem, v);
            } else {
                MenuItemCompat.setActionView(refreshItem, null);
            }
        }
    }
}
项目:amar-android-demo    文件:DeleteDropZoneView.java   
public DeleteDropZoneView(Context context) {
    super(context);

    bounds = new Rect();

    textPaintStraight = createTextPaint();
    textPaintStraight.setColor(Color.WHITE);

    textPaintRed = createTextPaint();
    textPaintRed.setColor(Color.RED);

    bitmapPaint = createBaseBitmapPaint();

    bitmapPaintRed = createBaseBitmapPaint();
    ColorFilter filter = new LightingColorFilter(Color.RED, 1);
    bitmapPaintRed.setColorFilter(filter);

    setBackgroundColor(Color.BLACK);
    getBackground().setAlpha(200);
}
项目: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);
        }
    });
}
项目:OpenSudoku    文件:IMPopupDialog.java   
public void updateNumber(Integer number) {
    mSelectedNumber = number;

    LightingColorFilter selBkgColorFilter = new LightingColorFilter(
            mContext.getResources().getColor(R.color.im_number_button_selected_background), 0);

    for (Map.Entry<Integer, Button> entry : mNumberButtons.entrySet()) {
        Button b = entry.getValue();
        if (entry.getKey().equals(mSelectedNumber)) {
            b.setTextAppearance(mContext, android.R.style.TextAppearance_Large_Inverse);
            b.getBackground().setColorFilter(selBkgColorFilter);
        } else {
            b.setTextAppearance(mContext, android.R.style.TextAppearance_Widget_Button);
            b.getBackground().setColorFilter(null);
        }
    }
}
项目: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);
}
项目: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);
}
项目:droidar    文件:DragAndDropListener.java   
private ImageView getImageView(View source, Activity activity,
        RelativeLayout c, LayoutParams params) {
    if (imageView == null) {
        final Bitmap bitmap = IO.loadBitmapFromView(source);
        final Paint shadowPaint = new Paint();
        shadowPaint.setAlpha(180);
        // http://stackoverflow.com/questions/7048941/how-to-use-the-lightingcolorfilter-to-make-the-image-form-dark-to-light
        shadowPaint.setColorFilter(new LightingColorFilter(0x11333333,
                0x00000000));

        imageView = new ImageView(activity) {

            @Override
            protected void onDraw(Canvas canvas) {
                // First draw shadow
                float dist = 2;
                canvas.drawBitmap(bitmap, dist, dist, shadowPaint);
                // then draw normal image view
                super.onDraw(canvas);
            }
        };
        imageView.setImageBitmap(bitmap);
        c.addView(imageView);
    }
    return imageView;
}
项目:lineagex86    文件:NotificationStation.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    logd("onCreate(%s)", savedInstanceState);
    super.onCreate(savedInstanceState);

    int colorPrimaryDark = getResources().getColor(R.color.theme_primary_dark);
    mFilter = new LightingColorFilter(colorPrimaryDark, colorPrimaryDark);
}
项目: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));
    }
}
项目:susi_android_v1    文件: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);
}
项目:EasyTodo    文件:ColorLinearLayout.java   
@Override
public void onColorChanged(int color) {
    if (getBackground() != null
            && !(getBackground() instanceof ColorDrawable)) {
        getBackground().setColorFilter(new LightingColorFilter(color, 1));
    } else {
        setBackgroundColor(color);
    }
}
项目:insapp-android    文件:Utils.java   
public static Bitmap darkenBitmap(Bitmap bitmap) {
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint(Color.RED);
    ColorFilter filter = new LightingColorFilter(0xffbababa, 0x00000000);

    paint.setColorFilter(filter);
    canvas.drawBitmap(bitmap, new Matrix(), paint);

    return bitmap;
}
项目: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;
    }
项目: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;
}
项目:Tower-develop    文件:MarkerWithText.java   
/**
 * Copied from:
 * http://stackoverflow.com/questions/18335642/how-to-draw-text-
 * in-default-marker-of-google-map-v2?lq=1
 */
private static Bitmap drawTextToBitmap(Context gContext, int gResId, int color, String gText) {
    Resources resources = gContext.getResources();
    float scale = resources.getDisplayMetrics().density;
    Bitmap bitmap = BitmapFactory.decodeResource(resources, gResId);

    android.graphics.Bitmap.Config bitmapConfig = bitmap.getConfig();
    if (bitmapConfig == null) {
        bitmapConfig = android.graphics.Bitmap.Config.ARGB_8888;
    }
    bitmap = bitmap.copy(bitmapConfig, true);

    // copy bitmap to canvas, replace white with colour
    Paint paint = new Paint();
    paint.setColorFilter(new LightingColorFilter(0x000000, color));
    Canvas canvas = new Canvas(bitmap);
    canvas.drawBitmap(bitmap, 0, 0, paint);

    paint = new Paint(Paint.ANTI_ALIAS_FLAG);
    paint.setColor(Color.BLACK);
    paint.setTextSize((int) (15 * scale));
    paint.setShadowLayer(1f, 0f, 1f, Color.WHITE);

    Rect bounds = new Rect();
    paint.getTextBounds(gText, 0, gText.length(), bounds);
    int x = (bitmap.getWidth() - bounds.width()) / 2;
    int y = (bitmap.getHeight() + bounds.height()) * 5 / 12; // At 5/12 from
                                                                // the top
                                                                // so it
                                                                // stays on
                                                                // the
                                                                // center

    canvas.drawText(gText, x, y, paint);

    return bitmap;
}
项目:deathly_adiutor_free    文件: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));
    }
}
项目: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());
}
项目:AyoSunny    文件:ImageLightingFilterView.java   
public ImageLightingFilterView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mContext = context;

    // 初始化画笔
    initPaint();

    // 初始化资源
    initRes(context);

    setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            /*
             * 判断控件是否被点击过
             */
            if (isClick) {
                // 如果已经被点击了则点击时设置颜色过滤为空还原本色
                mPaint.setColorFilter(null);
                isClick = false;
            } else {
                // 如果未被点击则点击时设置颜色过滤后为黄色
                mPaint.setColorFilter(new LightingColorFilter(0xFFFFFFFF, 0X00FFFF00));
                isClick = true;
            }

            // 记得重绘
            invalidate();
        }
    });
}
项目: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));
    }
}
项目: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);
}
项目:AppHub    文件:WifiQrView.java   
@Override
protected void onFinishInflate() {
    super.onFinishInflate();
    setUIFromWifi();

    ImageView qrImage = (ImageView) findViewById(R.id.wifi_qr_code);

    // Replace all blacks with the background blue.
    qrImage.setColorFilter(new LightingColorFilter(0xffffffff, getResources().getColor(R.color.swap_blue)));

    Button openQr = (Button) findViewById(R.id.btn_qr_scanner);
    openQr.setOnClickListener(new Button.OnClickListener() {
        @Override
        public void onClick(View v) {
            getActivity().initiateQrScan();
        }
    });

    // TODO: Unregister this receiver properly.
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(
            new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    setUIFromWifi();
                }
            },
            new IntentFilter(WifiStateChangeService.BROADCAST)
    );
}
项目: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));
    }
}