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