當前位置: 首頁>>代碼示例>>Java>>正文


Java Drawable.setFilterBitmap方法代碼示例

本文整理匯總了Java中android.graphics.drawable.Drawable.setFilterBitmap方法的典型用法代碼示例。如果您正苦於以下問題:Java Drawable.setFilterBitmap方法的具體用法?Java Drawable.setFilterBitmap怎麽用?Java Drawable.setFilterBitmap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.drawable.Drawable的用法示例。


在下文中一共展示了Drawable.setFilterBitmap方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: applyTo

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@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);
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:19,代碼來源:DrawableProperties.java

示例2: setFilterBitmap

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
@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);
    }
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:ArrayDrawable.java

示例3: createIconDrawable

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
/**
     * Returns a FastBitmapDrawable with the icon, accurately sized.
     */
    public Drawable createIconDrawable(Bitmap icon) {
        Drawable d = new FastBitmapDrawable(icon);
        d.setFilterBitmap(true);
        //The next 3 lines are the bulf of how to do it. Change ic_allapps_new in the next line to the name of your png and make sure it is in res/drawable-[sizes], appropriately sized.
        Drawable outer = LauncherAppState.getInstance().getContext().getResources().getDrawable(R.drawable.appbg);
        Drawable drawableArray[]= new Drawable[]{outer,d};
        LayerDrawable layerDraw = new LayerDrawable(drawableArray);
//The following 2 just change the varible to use the new layer drawable.  the resize is important and why it is better to do it here than BubbleTextView.
        resizeIconDrawable(layerDraw);
        return layerDraw;
    }
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:15,代碼來源:Launcher.java

示例4: generateShortcutPreview

import android.graphics.drawable.Drawable; //導入方法依賴的package包/類
private Bitmap generateShortcutPreview(
        Launcher launcher, ActivityInfo 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));
    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;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:45,代碼來源:WidgetPreviewLoader.java


注:本文中的android.graphics.drawable.Drawable.setFilterBitmap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。