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


Java Canvas.drawARGB方法代码示例

本文整理汇总了Java中android.graphics.Canvas.drawARGB方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.drawARGB方法的具体用法?Java Canvas.drawARGB怎么用?Java Canvas.drawARGB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.graphics.Canvas的用法示例。


在下文中一共展示了Canvas.drawARGB方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRoundedCornerBitmap

import android.graphics.Canvas; //导入方法依赖的package包/类
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap) {
    Bitmap outBitmap = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(outBitmap);
    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 = bitmap.getWidth() / 2;
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, roundPX, roundPX, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    return outBitmap;
}
 
开发者ID:xiaoxiaoqingyi,项目名称:mine-android-repository,代码行数:18,代码来源:BitmapUtils.java

示例2: getRCB

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * 图片圆角处理
 *
 * @param bitmap
 * @param roundPX
 * @return
 */
public static Bitmap getRCB(Bitmap bitmap, float roundPX) {
    // RCB means
    // Rounded
    // Corner Bitmap
    Bitmap dstbmp = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(dstbmp);

    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(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    return dstbmp;
}
 
开发者ID:xiaoxiaoqingyi,项目名称:mine-android-repository,代码行数:28,代码来源:BitmapUtils.java

示例3: getRoundedCornerBitmap

import android.graphics.Canvas; //导入方法依赖的package包/类
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, float pixels) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap
            .getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    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(0xff424242);

    canvas.drawRoundRect(rectF, pixels, pixels, paint);

    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);

    return output;
}
 
开发者ID:MobileDev418,项目名称:chat-sdk-android-push-firebase,代码行数:21,代码来源:ChatBubbleImageView.java

示例4: getRoundedCornerBitmap

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * 获得圆角图片的方法
 *
 * @param bitmap
 * @param roundPx 一般设成14
 * @return
 */
public static Bitmap getRoundedCornerBitmap(Bitmap bitmap, float roundPx) {

    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);

    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:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:29,代码来源:ImageUtils.java

示例5: getCircleBitmap

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * 获取圆形图片方法
 * @param bitmap
 * @param pixels
 * @return Bitmap
 * @author caizhiming
 */
private Bitmap getCircleBitmap(Bitmap bitmap, int pixels) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;

    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    int x = bitmap.getWidth();

    canvas.drawCircle(x / 2, x / 2, x / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    return output;


}
 
开发者ID:snowwolf10285,项目名称:PicShow-zhaipin,代码行数:28,代码来源:XCRoundImageView.java

示例6: getRoundedCornerBitmap

import android.graphics.Canvas; //导入方法依赖的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

示例7: getRoundBitmap

import android.graphics.Canvas; //导入方法依赖的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

示例8: toOvalBitmap

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * Create a new bitmap that has all pixels beyond the oval shape transparent. Old bitmap is
 * recycled.
 */
public static Bitmap toOvalBitmap(@NonNull Bitmap bitmap) {
  int width = bitmap.getWidth();
  int height = bitmap.getHeight();
  Bitmap output = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);

  Canvas canvas = new Canvas(output);

  int color = 0xff424242;
  Paint paint = new Paint();

  paint.setAntiAlias(true);
  canvas.drawARGB(0, 0, 0, 0);
  paint.setColor(color);

  RectF rect = new RectF(0, 0, width, height);
  canvas.drawOval(rect, paint);
  paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
  canvas.drawBitmap(bitmap, 0, 0, paint);

  bitmap.recycle();

  return output;
}
 
开发者ID:prashantsaini1,项目名称:android-titanium-imagecropper,代码行数:28,代码来源:CropImage.java

示例9: toRound

import android.graphics.Canvas; //导入方法依赖的package包/类
/**
 * 转为圆形图片
 *
 * @param src     源图片
 * @param recycle 是否回收
 * @return 圆形图片
 */
public static Bitmap toRound(Bitmap src, boolean recycle) {
    if (isEmptyBitmap(src)) return null;
    int width = src.getWidth();
    int height = src.getHeight();
    int radius = Math.min(width, height) >> 1;
    Bitmap ret = Bitmap.createBitmap(width, height, src.getConfig());
    Paint paint = new Paint();
    Canvas canvas = new Canvas(ret);
    Rect rect = new Rect(0, 0, width, height);
    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    canvas.drawCircle(width >> 1, height >> 1, radius, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(src, rect, rect, paint);
    if (recycle && !src.isRecycled()) src.recycle();
    return ret;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:25,代码来源:ImageUtils.java

示例10: getCircleBitmap

import android.graphics.Canvas; //导入方法依赖的package包/类
private Bitmap getCircleBitmap(final int radius)
{
       final Bitmap output = Bitmap.createBitmap(originBitmap.getWidth(), originBitmap.getHeight(), Bitmap.Config.ARGB_8888);
       final Canvas canvas = new Canvas(output);
       final Paint paint = new Paint();
       final Rect rect = new Rect((int)(x - radius), (int)(y - radius), (int)(x + radius), (int)(y + radius));

       paint.setAntiAlias(true);
       canvas.drawARGB(0, 0, 0, 0);
       canvas.drawCircle(x, y, radius, paint);

       paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
       canvas.drawBitmap(originBitmap, rect, rect, paint);

       return output;
   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:17,代码来源:bilibili.java

示例11: drawRootToBitmap

import android.graphics.Canvas; //导入方法依赖的package包/类
private static void drawRootToBitmap(ViewRootData config, Bitmap bitmap) {
    // now only dim supported
    if ((config._layoutParams.flags & FLAG_DIM_BEHIND) == FLAG_DIM_BEHIND) {
        Canvas dimCanvas = new Canvas(bitmap);

        int alpha = (int) (255 * config._layoutParams.dimAmount);
        dimCanvas.drawARGB(alpha, 0, 0, 0);
    }

    Canvas canvas = new Canvas(bitmap);
    canvas.translate(config._winFrame.left, config._winFrame.top);
    config._view.draw(canvas);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:14,代码来源:Falcon.java

示例12: getCircleBitmap

import android.graphics.Canvas; //导入方法依赖的package包/类
static Bitmap getCircleBitmap(Drawable drawable, int color) {
    Bitmap bitmap = drawableToBitmap(drawable);

    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
            bitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    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(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);

    return output;
}
 
开发者ID:robertlevonyan,项目名称:materialExpansionPanel,代码行数:21,代码来源:ExpandableUtils.java

示例13: getCircleBitmap

import android.graphics.Canvas; //导入方法依赖的package包/类
private Bitmap getCircleBitmap(final int radius) {
    final Bitmap output = Bitmap.createBitmap(originBitmap.getWidth(), originBitmap.getHeight(), Bitmap.Config.ARGB_8888);
    final Canvas canvas = new Canvas(output);
    final Paint paint = new Paint();
    final Rect rect = new Rect((int) (x - radius), (int) (y - radius), (int) (x + radius), (int) (y + radius));

    paint.setAntiAlias(true);
    canvas.drawARGB(0, 0, 0, 0);
    canvas.drawCircle(x, y, radius, paint);

    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(originBitmap, rect, rect, paint);

    return output;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:RippleView.java

示例14: getRoundedCroppedBitmap

import android.graphics.Canvas; //导入方法依赖的package包/类
public static Bitmap getRoundedCroppedBitmap(Bitmap bitmap, int radius) {
    Bitmap finalBitmap;
    if (bitmap.getWidth() != radius || bitmap.getHeight() != radius)
        finalBitmap = Bitmap.createScaledBitmap(bitmap, radius, radius,
                false);
    else
        finalBitmap = bitmap;
    Bitmap output = Bitmap.createBitmap(finalBitmap.getWidth(),
            finalBitmap.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, finalBitmap.getWidth(),
            finalBitmap.getHeight());

    paint.setAntiAlias(true);
    paint.setFilterBitmap(true);
    paint.setDither(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(Color.parseColor("#BAB399"));
    canvas.drawCircle(finalBitmap.getWidth() / 2 + 0.7f,
            finalBitmap.getHeight() / 2 + 0.7f,
            finalBitmap.getWidth() / 2 + 0.1f, paint);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
    canvas.drawBitmap(finalBitmap, rect, rect, paint);

    return output;
}
 
开发者ID:pawanchauhan05,项目名称:AndroidUtility,代码行数:29,代码来源:CircularImageView.java

示例15: getRoundedCroppedBitmap

import android.graphics.Canvas; //导入方法依赖的package包/类
private Bitmap getRoundedCroppedBitmap(Bitmap bitmap, int radius) {
    Bitmap finalBitmap;

    if (bitmap.getWidth() != radius || bitmap.getHeight() != radius) {
        finalBitmap = Bitmap.createScaledBitmap(bitmap, radius, radius, false);
    } else {
        finalBitmap = bitmap;
    }

    Bitmap output = Bitmap.createBitmap(finalBitmap.getWidth(),
            finalBitmap.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, finalBitmap.getWidth(),
            finalBitmap.getHeight());

    paint.setAntiAlias(true);
    paint.setFilterBitmap(true);
    paint.setDither(true);
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(Color.parseColor("#BAB399"));
    canvas.drawCircle(finalBitmap.getWidth() / 2,
            finalBitmap.getHeight() / 2,
            finalBitmap.getWidth() / 2, paint);
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(finalBitmap, rect, rect, paint);

    return output;
}
 
开发者ID:MindorksOpenSource,项目名称:android-mvp-architecture,代码行数:31,代码来源:RoundedImageView.java


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