标签:程序 width hfs desc write puts nal 推荐 ica
* oracle‘s jdk 1.8以上
* 若选择了微软雅黑字体又是代码部署到Linux,则需要安装微软雅黑字体,字体安装方式自行google
这是使用白色框底来作背景图1.
java code //这里从项目resources加载背景图,读文件到输入流,代码作了简列 InputStream background = null BufferedImage zoomPicture = ImageIO.read(background);
头像裁剪成半径
//头像半径
public static final int PROFILE_RADIUS = 80;
// 2. 头像裁剪成圆形
BufferedImage roundedImage = SharedImageUtils.createRoundedImage(new URL(userProfileUrl).openStream(),
SharedImageUtils.PROFILE_RADIUS);
绘画位置
/* 要放置的头像y坐标 */
public static final int PROFILE_Y = 1056;
/* 要放置的头像X坐标 */
public static final int PROFILE_X = 90;
//頭像旁邊附帶文字(ps:字体是微软雅黑,linux不具备有,需要安装,)
BufferedImage profileImage = SharedImageUtils.mergePicture(zoomPicture,
roundedImage,
nickName + " 为你推荐网批货源",
SharedImageUtils.PROFILE_X,
SharedImageUtils.PROFILE_Y,
SharedImageUtils.PROFILE_RADIUS,
SharedImageUtils.PROFILE_RADIUS);
public static final int COPYWRITER_X = 150;
/* 商店图案Y位置 */
public static final int SHOP_PIC_Y = 70;
/*商店图案位置*/
public static final int SHOP_PIC_X = 93;
/* 商店图案寬度 */
public static final int SHOP_PIC_WIDTH = 900;
/* 商店图案長度 */
public static final int SHOP_PIC_LENGTH = 950;
shopImage = SharedImageUtils.mergePicture(profileImage, shopImage, null,
SharedImageUtils.SHOP_PIC_X,
SharedImageUtils.SHOP_PIC_Y,
SharedImageUtils.SHOP_PIC_WIDTH, SharedImageUtils.SHOP_PIC_LENGTH);
BufferedImage textImage = SharedImageUtils.drawTextInImage(shopImage, "档口: " + shopName, 150, 1200);
//添加文案
BufferedImage mergeImage = SharedImageUtils.drawTextInImage(textImage, "地址: " + shopAddr, 150, 1280);
/* 要放置的二维码寬度 */
public static final int QRCODE_WIDTH = 230;
/* 要放置的二维码長度 */
public static final int QRCODE_LENGTH = 230;
/* 要放置的二维码Y位置 往下为大值,往上为小值 */
public static final int QRCODE_Y = 1070;
/*要放置的二维码X位置 往下为大值,往上为小值 */
public static final int QRCODE_X = 740;
BufferedImage shopQrBuffer = ImageIO.read(new URL(shopQrUrl));
mergeImage = SharedImageUtils.mergeQrcode(mergeImage,
shopQrBuffer,
"扫描或长按小程序码",
SharedImageUtils.QRCODE_X,
SharedImageUtils.QRCODE_Y,
SharedImageUtils.QRCODE_WIDTH,
SharedImageUtils.QRCODE_LENGTH);
// 5. 生成分享图
ImageIO.write(mergeImage, "jpg", response.getOutputStream());
[link](https://picasaweb.google.com/106437634114917759264/6630213808569212145#6630213806186676098 "background.jpg)
这是使用的背景图是白色框底?
标签:程序 width hfs desc write puts nal 推荐 ica
原文地址:https://www.cnblogs.com/vincentl/p/10216081.html