本文整理汇总了Java中android.support.v4.graphics.drawable.RoundedBitmapDrawable.setAntiAlias方法的典型用法代码示例。如果您正苦于以下问题:Java RoundedBitmapDrawable.setAntiAlias方法的具体用法?Java RoundedBitmapDrawable.setAntiAlias怎么用?Java RoundedBitmapDrawable.setAntiAlias使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.graphics.drawable.RoundedBitmapDrawable
的用法示例。
在下文中一共展示了RoundedBitmapDrawable.setAntiAlias方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initHalloweenTheme
import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //导入方法依赖的package包/类
private void initHalloweenTheme() {
if (!isHalloween) {
return;
}
Bitmap bmp = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.ground);
RoundedBitmapDrawable dr = RoundedBitmapDrawableFactory.create(getContext().getResources(), bmp);
dr.setCornerRadius(dialogRadius);
dr.setAntiAlias(true);
ground.setBackgroundDrawable(dr);
plane.setImageResource(R.drawable.witch);
tomb.setImageResource(R.drawable.tomb_hw);
moon.setVisibility(View.VISIBLE);
ground.setVisibility(View.VISIBLE);
pumpkin.setVisibility(View.VISIBLE);
wifiOn.getBackground().mutate().setColorFilter(ContextCompat.getColor(getContext(), R.color.colorNoInternetGradCenterH), PorterDuff.Mode.SRC_IN);
mobileOn.getBackground().mutate().setColorFilter(ContextCompat.getColor(getContext(), R.color.colorNoInternetGradCenterH), PorterDuff.Mode.SRC_IN);
airplaneOff.getBackground().mutate().setColorFilter(ContextCompat.getColor(getContext(), R.color.colorNoInternetGradCenterH), PorterDuff.Mode.SRC_IN);
}
示例2: onDraw
import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas canvas) {
if (bitmap != null) {
int size = Math.min(canvas.getWidth(), canvas.getHeight());
if (size != this.size) {
this.size = size;
bitmap = ThumbnailUtils.extractThumbnail(bitmap, size, size);
RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap);
roundedBitmapDrawable.setCornerRadius(size / 2);
roundedBitmapDrawable.setAntiAlias(true);
bitmap = ImageUtils.drawableToBitmap(roundedBitmapDrawable);
}
canvas.drawBitmap(bitmap, 0, 0, paint);
}
}
示例3: onLargeIconAvailable
import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //导入方法依赖的package包/类
@Override
public void onLargeIconAvailable(
Bitmap icon, int fallbackColor, boolean isFallbackColorDefault) {
if (icon == null) {
mIconGenerator.setBackgroundColor(fallbackColor);
icon = mIconGenerator.generateIconForUrl(mItem.getUrl());
mItemView.setIcon(new BitmapDrawable(getResources(), icon));
mItem.setTileType(isFallbackColorDefault ? MostVisitedTileType.ICON_DEFAULT
: MostVisitedTileType.ICON_COLOR);
} else {
RoundedBitmapDrawable roundedIcon = RoundedBitmapDrawableFactory.create(
getResources(), icon);
int cornerRadius = Math.round(ICON_CORNER_RADIUS_DP
* getResources().getDisplayMetrics().density * icon.getWidth()
/ mDesiredIconSize);
roundedIcon.setCornerRadius(cornerRadius);
roundedIcon.setAntiAlias(true);
roundedIcon.setFilterBitmap(true);
mItemView.setIcon(roundedIcon);
mItem.setTileType(MostVisitedTileType.ICON_REAL);
}
mSnapshotMostVisitedChanged = true;
if (mIsInitialLoad) loadTaskCompleted();
}
示例4: updateUi
import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //导入方法依赖的package包/类
public void updateUi(Card card) {
TextView extraText = (TextView) findViewById(R.id.extra_text);
TextView primaryText = (TextView) findViewById(R.id.primary_text);
final ImageView imageView = (ImageView) findViewById(R.id.main_image);
extraText.setText(card.getExtraText());
primaryText.setText(card.getTitle());
// Create a rounded drawable.
int resourceId = card.getLocalImageResourceId(getContext());
Bitmap bitmap = BitmapFactory
.decodeResource(getContext().getResources(), resourceId);
RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(getContext().getResources(), bitmap);
drawable.setAntiAlias(true);
drawable.setCornerRadius(
Math.max(bitmap.getWidth(), bitmap.getHeight()) / 2.0f);
imageView.setImageDrawable(drawable);
}
示例5: onBitmapLoaded
import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //导入方法依赖的package包/类
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
// Updating icons from Java is not supported prior to API 11.
if (!AppConstants.Versions.feature11Plus) {
return;
}
final Drawable drawable;
if (cornerRadius > 0) {
final RoundedBitmapDrawable roundedBitmapDrawable;
roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(resources, bitmap);
roundedBitmapDrawable.setCornerRadius(cornerRadius);
roundedBitmapDrawable.setAntiAlias(true);
drawable = roundedBitmapDrawable;
} else {
drawable = new BitmapDrawable(resources, bitmap);
}
preference.setIcon(drawable);
}
示例6: transform
import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //导入方法依赖的package包/类
private Bitmap transform(Bitmap source, int size) {
if (source != null) {
RoundedBitmapDrawable drawable =
RoundedBitmapDrawableFactory.create(getResources(), source);
drawable.setCornerRadius(100);
Bitmap.Config config = source.getConfig() != null ? source.getConfig() : Bitmap.Config.ARGB_8888;
Bitmap output = Bitmap.createBitmap(size, size, config);
Canvas canvas = new Canvas(output);
drawable.setAntiAlias(true);
drawable.setBounds(0, 0, size, size);
drawable.draw(canvas);
if (!source.equals(output)) {
source.recycle();
}
return output;
}
return null;
}
示例7: clipToRound
import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //导入方法依赖的package包/类
/**
* 把 Bitmap 变圆。
*
* @param context Context
* @param bitmap 要处理的 Bitmap
* @return 圆形的 Bitmap
*/
public static Bitmap clipToRound(Context context, Bitmap bitmap) {
final RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(context.getResources(), bitmap);
drawable.setAntiAlias(true);
drawable.setCircular(true);
drawable.setBounds(0, 0, bitmap.getWidth(), bitmap.getHeight());
bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
drawable.draw(canvas);
return bitmap;
}
示例8: getRoundBitmap
import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //导入方法依赖的package包/类
private Bitmap getRoundBitmap(@DrawableRes int drawable, int size) {
Bitmap bitmap = ImageUtils.drawableToBitmap(ContextCompat.getDrawable(getContext(), drawable));
bitmap = Bitmap.createBitmap(bitmap, bitmap.getWidth() / 6, bitmap.getHeight() / 6, (int) (0.666 * bitmap.getWidth()), (int) (0.666 * bitmap.getHeight()));
bitmap = ThumbnailUtils.extractThumbnail(bitmap, size, size);
RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap);
roundedBitmapDrawable.setCornerRadius(size / 2);
roundedBitmapDrawable.setAntiAlias(true);
return ImageUtils.drawableToBitmap(roundedBitmapDrawable);
}
示例9: getCircleDrawable
import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //导入方法依赖的package包/类
public static RoundedBitmapDrawable getCircleDrawable(Context context, Bitmap bitmap) {
RoundedBitmapDrawable circleDrawable = RoundedBitmapDrawableFactory.create(context
.getResources(), bitmap);
circleDrawable.setAntiAlias(true);
circleDrawable.setCornerRadius(((float) Math.min(bitmap.getWidth(), bitmap.getHeight()))
/ 2.0f);
return circleDrawable;
}
示例10: getRoundedDrawable
import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //导入方法依赖的package包/类
public static RoundedBitmapDrawable getRoundedDrawable(Context context, Bitmap bitmap, float
cornerRadius) {
RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(context
.getResources(), bitmap);
roundedBitmapDrawable.setAntiAlias(true);
roundedBitmapDrawable.setCornerRadius(cornerRadius);
return roundedBitmapDrawable;
}
示例11: getRoundedCornerDrawable
import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //导入方法依赖的package包/类
public static Drawable getRoundedCornerDrawable(Resources resources, Bitmap bitmap, float scale) {
if (resources == null || bitmap == null)
return null;
RoundedBitmapDrawable round = RoundedBitmapDrawableFactory.create(resources, bitmap);
round.setCornerRadius(round.getIntrinsicWidth() / scale);
round.setAntiAlias(true);
return round;
}
示例12: TransformToRounded
import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //导入方法依赖的package包/类
public static Bitmap TransformToRounded(Bitmap source, Context mContext, int width, int heigth) {
// Create the RoundedBitmapDrawable.
RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(mContext.getResources(), source);
drawable.setCircular(true);
//drawable.setCornerRadius(mContext.getCornerRadius(source));
Bitmap output = Bitmap.createBitmap(width, heigth, source.getConfig());
Canvas canvas = new Canvas(output);
drawable.setAntiAlias(true);
drawable.setBounds(0, 0, width, heigth);
drawable.draw(canvas);
if (source != output) {
source.recycle();
}
return output;
}
示例13: getRoundedBitmap
import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //导入方法依赖的package包/类
/**
* Return a rounded bitmap version of the given bitmap
*
* @param res the context resources
* @param srcBitmap the bitmap with the image
* @return the RoundedBitmapDrawable with the rounded bitmap
*/
public static RoundedBitmapDrawable getRoundedBitmap(Resources res, Bitmap srcBitmap) {
RoundedBitmapDrawable bitmapDrawable = RoundedBitmapDrawableFactory.create(res, srcBitmap);
int radius = Math.min(srcBitmap.getWidth(), srcBitmap.getHeight());
bitmapDrawable.setCornerRadius(radius);
bitmapDrawable.setAntiAlias(true);
return bitmapDrawable;
}
示例14: onDraw
import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas canvas) {
Bitmap image = ImageUtils.drawableToBitmap(getDrawable());
if (image != null) {
int size = Math.min(getWidth(), getHeight());
image = ThumbnailUtils.extractThumbnail(image, size, size);
RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), image);
roundedBitmapDrawable.setCornerRadius(size / 2);
roundedBitmapDrawable.setAntiAlias(true);
canvas.drawBitmap(ImageUtils.drawableToBitmap(roundedBitmapDrawable), 0, 0, paint);
}
}
示例15: onDraw
import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas canvas) {
Bitmap image = Utils.drawableToBitmap(getDrawable());
if (image != null) {
int size = Math.min(getWidth(), getHeight());
image = ThumbnailUtils.extractThumbnail(image, size, size);
RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), image);
roundedBitmapDrawable.setCornerRadius(size / 2);
roundedBitmapDrawable.setAntiAlias(true);
canvas.drawBitmap(Utils.drawableToBitmap(roundedBitmapDrawable), 0, 0, paint);
}
}