当前位置: 首页>>代码示例>>Java>>正文


Java Mode类代码示例

本文整理汇总了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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:24,代码来源:BitmapHelper.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:ImageLoaderUtil.java

示例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();
    }
}
 
开发者ID:santalu,项目名称:ticket-view,代码行数:24,代码来源:TicketView.java

示例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;
}
 
开发者ID:AnnyBaby,项目名称:Mvp-Retrofit-Rxjava-Rxbus,代码行数:32,代码来源:BitmapUtils.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:22,代码来源:DrawableWrapperDonut.java

示例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;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:25,代码来源:TransportOptionsAdapter.java

示例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;
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:18,代码来源:ButtonFloat.java

示例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;
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:24,代码来源:LayoutRipple.java

示例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;
}
 
开发者ID:CoderCF,项目名称:TakePhoto,代码行数:28,代码来源:FileUtil.java

示例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;
}
 
开发者ID:VK2012,项目名称:AppCommonFrame,代码行数:26,代码来源:BitmapUtil.java

示例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;
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:25,代码来源:ImageHelper.java

示例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;
}
 
开发者ID:LanguidSheep,项目名称:sealtalk-android-master,代码行数:27,代码来源:BitmapUtils.java

示例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;
}
 
开发者ID:youth5201314,项目名称:XFrame,代码行数:33,代码来源:XBitmapUtils.java

示例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;
	}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:23,代码来源:BitmapUtil.java

示例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);
        }
    }
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:15,代码来源:PieItem.java


注:本文中的android.graphics.PorterDuff.Mode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。