XBitmapUtils.java 文件源码

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

项目:XFrame 作者:
/**
 * 合并
 *
 * @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;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号