本文整理汇总了Java中android.graphics.PorterDuff.Mode类的典型用法代码示例。如果您正苦于以下问题:Java Mode类的具体用法?Java Mode怎么用?Java Mode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Mode类属于android.graphics.PorterDuff包,在下文中一共展示了Mode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: roundBitmap
import android.graphics.PorterDuff.Mode; //导入依赖的package包/类
public static Bitmap roundBitmap(Bitmap bitmap, int i, int i2, float f, float f2, float f3,
float f4) throws Throwable {
int width = bitmap.getWidth();
int height = bitmap.getHeight();
Rect rect = new Rect(0, 0, width, height);
Bitmap createBitmap = (width == i && height == i2) ? Bitmap.createBitmap(bitmap.getWidth
(), bitmap.getHeight(), Config.ARGB_8888) : Bitmap.createBitmap(i, i2, Config
.ARGB_8888);
Canvas canvas = new Canvas(createBitmap);
Paint paint = new Paint();
Rect rect2 = new Rect(0, 0, i, i2);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(-12434878);
float[] fArr = new float[]{f, f, f2, f2, f3, f3, f4, f4};
ShapeDrawable shapeDrawable = new ShapeDrawable(new RoundRectShape(fArr, new RectF(0.0f,
0.0f, 0.0f, 0.0f), fArr));
shapeDrawable.setBounds(rect2);
shapeDrawable.draw(canvas);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect2, paint);
return createBitmap;
}
示例2: toRoundCorner
import android.graphics.PorterDuff.Mode; //导入依赖的package包/类
/**将图片改为圆角类型
* @param bitmap
* @param pixels
* @return
*/
public static Bitmap toRoundCorner(Bitmap bitmap, int pixels) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
final float roundPx = pixels;
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
示例3: init
import android.graphics.PorterDuff.Mode; //导入依赖的package包/类
private void init(AttributeSet attrs) {
eraser.setXfermode(new PorterDuffXfermode(Mode.CLEAR));
dashPaint.setARGB(255, 200, 200, 200);
dashPaint.setStyle(Style.STROKE);
dashPaint.setStrokeWidth(4);
dashPaint.setPathEffect(new DashPathEffect(new float[] { 4, 8 }, 0));
borderPaint.setARGB(255, 200, 200, 200);
borderPaint.setStyle(Style.STROKE);
borderPaint.setStrokeWidth(4);
setLayerType(LAYER_TYPE_HARDWARE, null);
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.TicketView);
try {
orientation = a.getInt(R.styleable.TicketView_tv_orientation, Orientation.VERTICAL);
holeRadius = a.getFloat(R.styleable.TicketView_tv_holeRadius, DEFAULT_RADIUS);
anchorViewId = a.getResourceId(R.styleable.TicketView_tv_anchor, NO_VALUE);
} finally {
a.recycle();
}
}
示例4: getRoundBitmap
import android.graphics.PorterDuff.Mode; //导入依赖的package包/类
/**
* 图片圆角
*
* @param bitmap
* @param pixels
* @return
*/
public static Bitmap getRoundBitmap(Bitmap bitmap, int pixels) {
if (bitmap == null) {
return null;
}
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xffffffff;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
final float roundPx = pixels;
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
示例5: updateTint
import android.graphics.PorterDuff.Mode; //导入依赖的package包/类
private boolean updateTint(int[] state) {
if (!isCompatTintEnabled()) {
return false;
}
ColorStateList tintList = this.mState.mTint;
Mode tintMode = this.mState.mTintMode;
if (tintList == null || tintMode == null) {
this.mColorFilterSet = false;
clearColorFilter();
return false;
}
int color = tintList.getColorForState(state, tintList.getDefaultColor());
if (this.mColorFilterSet && color == this.mCurrentColor && tintMode == this.mCurrentMode) {
return false;
}
setColorFilter(color, tintMode);
this.mCurrentColor = color;
this.mCurrentMode = tintMode;
this.mColorFilterSet = true;
return true;
}
示例6: getView
import android.graphics.PorterDuff.Mode; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = inflater.inflate(R.layout.transport_selection_list_item, parent, false);
}
TransportOption transport = (TransportOption) getItem(position);
ImageView imageView = ViewUtil.findById(convertView, R.id.icon);
TextView textView = ViewUtil.findById(convertView, R.id.text);
TextView subtextView = ViewUtil.findById(convertView, R.id.subtext);
imageView.getBackground().setColorFilter(transport.getBackgroundColor(), Mode.MULTIPLY);
imageView.setImageResource(transport.getDrawable());
textView.setText(transport.getDescription());
if (transport.getSimName().isPresent()) {
subtextView.setText(transport.getSimName().get());
subtextView.setVisibility(View.VISIBLE);
} else {
subtextView.setVisibility(View.GONE);
}
return convertView;
}
示例7: cropCircle
import android.graphics.PorterDuff.Mode; //导入依赖的package包/类
public Bitmap cropCircle(Bitmap bitmap) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2,
bitmap.getWidth() / 2, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
示例8: cropRoundRect
import android.graphics.PorterDuff.Mode; //导入依赖的package包/类
/**
* @param bitmap
* @return 设置涟漪的边界,涟漪在这个区域里面可见。这里可以设置四角的弧度数
*/
public Bitmap cropRoundRect(Bitmap bitmap) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
RectF rectF = new RectF(0, 0, bitmap.getWidth(), bitmap.getHeight());
canvas.drawRoundRect(rectF, rippleBorderRadius, rippleBorderRadius, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
示例9: toRoundCorner
import android.graphics.PorterDuff.Mode; //导入依赖的package包/类
/**
* 将图片变为圆角
* @param bitmap 原Bitmap图片
* @param pixels 图片圆角的弧度(单位:像素(px))
* @return 带有圆角的图片(Bitmap 类型)
*/
public static Bitmap toRoundCorner(Bitmap bitmap, int pixels) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
final float roundPx = pixels;
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
示例10: getRoundedCornerBitmap
import android.graphics.PorterDuff.Mode; //导入依赖的package包/类
/**
* 获得圆角图片 . <br>
* @author liulongzhenhai 2012-8-1 下午5:24:57 <br>
* @param bitmap 图片
* @param roundPx 圆角度
* @return 图片
*/
public static Bitmap getRoundedCornerBitmap(final Bitmap bitmap, final float roundPx) {
final int w = bitmap.getWidth();
final int h = bitmap.getHeight();
final Bitmap output = Bitmap.createBitmap(w, h, Config.ARGB_8888);
final Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, w, h);
final RectF rectF = new RectF(rect);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
示例11: getRoundedCornerBitmap
import android.graphics.PorterDuff.Mode; //导入依赖的package包/类
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
if (bitmap == null) {
return null;
}
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap
.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
final float roundPx = pixels;
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}
示例12: getRoundedCornerBitmap
import android.graphics.PorterDuff.Mode; //导入依赖的package包/类
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
final float roundPx = 12;
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
if (null != bitmap) {
bitmap.recycle();
bitmap = null;
}
return output;
}
示例13: combineImagesToSameSize
import android.graphics.PorterDuff.Mode; //导入依赖的package包/类
/**
* 合并
*
* @param bgd 后景Bitmap
* @param fg 前景Bitmap
* @return 合成后Bitmap
*/
public static Bitmap combineImagesToSameSize(Bitmap bgd, Bitmap fg) {
Bitmap bmp;
int width = bgd.getWidth() < fg.getWidth() ? bgd.getWidth() : fg
.getWidth();
int height = bgd.getHeight() < fg.getHeight() ? bgd.getHeight() : fg
.getHeight();
if (fg.getWidth() != width && fg.getHeight() != height) {
fg = zoom(fg, width, height);
}
if (bgd.getWidth() != width && bgd.getHeight() != height) {
bgd = zoom(bgd, width, height);
}
bmp = Bitmap.createBitmap(width, height, Config.ARGB_8888);
Paint paint = new Paint();
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_ATOP));
Canvas canvas = new Canvas(bmp);
canvas.drawBitmap(bgd, 0, 0, null);
canvas.drawBitmap(fg, 0, 0, paint);
return bmp;
}
示例14: getRoundedCornerBitmap
import android.graphics.PorterDuff.Mode; //导入依赖的package包/类
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, float roundPx) {
System.gc();
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(),
Config.RGB_565);
// Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
System.gc();
return output;
}
示例15: setColor
import android.graphics.PorterDuff.Mode; //导入依赖的package包/类
public void setColor(PieController.ColorInfo colorInfo) {
mBackgroundPaint.setColor(colorInfo.bgColor);
mSelectedPaint.setColor(colorInfo.selectedColor);
mOutlinePaint.setColor(colorInfo.outlineColor);
if (mView instanceof ImageView) {
ImageView imageView = (ImageView)mView;
Drawable drawable = imageView.getDrawable();
if (drawable != null) {
drawable.setColorFilter(colorInfo.fgColor, Mode.SRC_ATOP);
imageView.setImageDrawable(drawable);
}
}
}