當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。