本文整理汇总了Java中android.support.v4.graphics.drawable.RoundedBitmapDrawable.setBounds方法的典型用法代码示例。如果您正苦于以下问题:Java RoundedBitmapDrawable.setBounds方法的具体用法?Java RoundedBitmapDrawable.setBounds怎么用?Java RoundedBitmapDrawable.setBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.graphics.drawable.RoundedBitmapDrawable
的用法示例。
在下文中一共展示了RoundedBitmapDrawable.setBounds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: transform
import android.support.v4.graphics.drawable.RoundedBitmapDrawable; //导入方法依赖的package包/类
@Override
public Bitmap transform(Bitmap source) {
RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(res, source);
drawable.setCornerRadius(getCornerRadius(source));
Bitmap output = Bitmap.createBitmap(source.getWidth(), source.getHeight(), source.getConfig());
Canvas canvas = new Canvas(output);
drawable.setAntiAlias(true);
drawable.setBounds(0, 0, source.getWidth(), source.getHeight());
drawable.draw(canvas);
if (source != output) {
source.recycle();
}
return output;
}