android.graphics.drawable.Drawable#setFilterBitmap()源码实例Demo

下面列出了android.graphics.drawable.Drawable#setFilterBitmap() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ImageLoader   文件: DrawableProperties.java
@SuppressLint("Range")
public void applyTo(Drawable drawable) {
  if (drawable == null) {
    return;
  }
  if (mAlpha != UNSET) {
    drawable.setAlpha(mAlpha);
  }
  if (mIsSetColorFilter) {
    drawable.setColorFilter(mColorFilter);
  }
  if (mDither != UNSET) {
    drawable.setDither(mDither != 0);
  }
  if (mFilterBitmap != UNSET) {
    drawable.setFilterBitmap(mFilterBitmap != 0);
  }
}
 
源代码2 项目: fresco   文件: DrawableProperties.java
@SuppressLint("Range")
public void applyTo(Drawable drawable) {
  if (drawable == null) {
    return;
  }
  if (mAlpha != UNSET) {
    drawable.setAlpha(mAlpha);
  }
  if (mIsSetColorFilter) {
    drawable.setColorFilter(mColorFilter);
  }
  if (mDither != UNSET) {
    drawable.setDither(mDither != 0);
  }
  if (mFilterBitmap != UNSET) {
    drawable.setFilterBitmap(mFilterBitmap != 0);
  }
}
 
源代码3 项目: FanXin-based-HuanXin   文件: DrawableUtils.java
/**
 * Sets various paint properties on the drawable
 * @param drawable Drawable on which to set the properties
 * @param properties wrapper around property values to set on the drawable
 */
public static void setDrawableProperties(Drawable drawable, DrawableProperties properties) {
  if (drawable == null || properties == null) {
    return;
  }

  drawable.setAlpha(properties.getAlpha());
  drawable.setColorFilter(properties.getColorFilter());
  drawable.setDither(properties.isDither());
  drawable.setFilterBitmap(properties.isFilterBitmap());
}
 
源代码4 项目: fresco   文件: ArrayDrawable.java
@Override
public void setFilterBitmap(boolean filterBitmap) {
  mDrawableProperties.setFilterBitmap(filterBitmap);
  for (int i = 0; i < mLayers.length; i++) {
    Drawable drawable = mLayers[i];
    if (drawable != null) {
      drawable.setFilterBitmap(filterBitmap);
    }
  }
}
 
源代码5 项目: openlauncher   文件: GroupDrawable.java
private void drawIcon(Canvas canvas, Drawable icon, float l, float t, float r, float b, Paint paint) {
    icon.setBounds((int) l, (int) t, (int) r, (int) b);
    icon.setFilterBitmap(true);
    icon.setAlpha(paint.getAlpha());
    icon.draw(canvas);
}
 
源代码6 项目: Trebuchet   文件: WidgetPreviewLoader.java
private Bitmap generateShortcutPreview(
        Launcher launcher, ResolveInfo info, int maxWidth, int maxHeight, Bitmap preview) {
    final Canvas c = new Canvas();
    if (preview == null) {
        preview = Bitmap.createBitmap(maxWidth, maxHeight, Config.ARGB_8888);
        c.setBitmap(preview);
    } else if (preview.getWidth() != maxWidth || preview.getHeight() != maxHeight) {
        throw new RuntimeException("Improperly sized bitmap passed as argument");
    } else {
        // Reusing bitmap. Clear it.
        c.setBitmap(preview);
        c.drawColor(0, PorterDuff.Mode.CLEAR);
    }

    Drawable icon = mutateOnMainThread(mIconCache.getFullResIcon(info.activityInfo));
    icon.setFilterBitmap(true);

    // Draw a desaturated/scaled version of the icon in the background as a watermark
    ColorMatrix colorMatrix = new ColorMatrix();
    colorMatrix.setSaturation(0);
    icon.setColorFilter(new ColorMatrixColorFilter(colorMatrix));
    icon.setAlpha((int) (255 * 0.06f));

    Resources res = mContext.getResources();
    int paddingTop = res.getDimensionPixelOffset(R.dimen.shortcut_preview_padding_top);
    int paddingLeft = res.getDimensionPixelOffset(R.dimen.shortcut_preview_padding_left);
    int paddingRight = res.getDimensionPixelOffset(R.dimen.shortcut_preview_padding_right);
    int scaledIconWidth = (maxWidth - paddingLeft - paddingRight);
    icon.setBounds(paddingLeft, paddingTop,
            paddingLeft + scaledIconWidth, paddingTop + scaledIconWidth);
    icon.draw(c);

    // Draw the final icon at top left corner.
    // TODO: use top right for RTL
    int appIconSize = launcher.getDeviceProfile().iconSizePx;

    icon.setAlpha(255);
    icon.setColorFilter(null);
    icon.setBounds(0, 0, appIconSize, appIconSize);
    icon.draw(c);

    c.setBitmap(null);
    return preview;
}