本文整理匯總了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);
}
}
示例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);
}
}
}
示例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;
}
示例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;
}