RoundTransformation.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:SnakeViewMaker 作者:
@Override
protected Bitmap transform(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {
    if (null == toTransform)
        return null;

    // outWidth is the width of the target ImageView,and the same to outHeight
    // all the ori bitmaps loaded may have different size, in order to the clipped
    // the bitmaps have the same size and shape,we use the target ImageView's size
    // to create bitmaps
    updateDrawBound(toTransform.getWidth(), toTransform.getHeight(), outWidth, outHeight);

    Bitmap bitmap = pool.get(drawWidth, drawHeight, Bitmap.Config.ARGB_8888);
    if (bitmap == null) {
        bitmap = Bitmap.createBitmap(drawWidth, drawHeight, Bitmap.Config.ARGB_8888);
    }
    bitmap.setHasAlpha(true);
    Canvas canvas = new Canvas(bitmap);
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setShader(new BitmapShader(toTransform, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP));
    drawRoundRect(canvas, paint);
    return bitmap;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号