关于安卓PortorDuffXmode的疑问
实现一个圆角图片,其实两段代码就是画图的先后顺序换了一下,然后模式换了一下,但是第二段代码没有效果,第一段可以实现,请问老师们怎么回事,谢谢!
第一段:
Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(newBitmap);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
canvas.drawBitmap(bitmap, 0, 0, paint);
RectF rect = new RectF(0, 0, getWidth(), getHeight());
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawRoundRect(rect, 50, 50, paint);
paint.setXfermode(null);
第二段:
Bitmap newBitmap = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(newBitmap);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
RectF rect = new RectF(0, 0, getWidth(), getHeight());
canvas.drawRoundRect(rect, 50, 50, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
canvas.drawBitmap(bitmap, 0, 0, paint);
paint.setXfermode(null);