public class ImageCombiner extends Object
| 构造器和说明 |
|---|
ImageCombiner(BufferedImage bgImage,
int width,
int height,
ZoomMode zoomMode,
OutputFormat outputFormat) |
ImageCombiner(BufferedImage bgImage,
OutputFormat outputFormat) |
ImageCombiner(int canvasWidth,
int canvasHeight,
Color bgColor,
OutputFormat outputFormat) |
ImageCombiner(int canvasWidth,
int canvasHeight,
OutputFormat outputFormat) |
ImageCombiner(String bgImageUrl,
int width,
int height,
ZoomMode zoomMode,
OutputFormat outputFormat) |
ImageCombiner(String bgImageUrl,
OutputFormat outputFormat) |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addElement(CombineElement element)
添加元素(图片或文本)
|
ImageElement |
addImageElement(BufferedImage image,
int x,
int y)
添加图片元素
|
ImageElement |
addImageElement(BufferedImage image,
int x,
int y,
int width,
int height,
ZoomMode zoomMode)
添加图片元素
|
ImageElement |
addImageElement(String imgUrl,
int x,
int y)
添加图片元素
|
ImageElement |
addImageElement(String imgUrl,
int x,
int y,
int width,
int height,
ZoomMode zoomMode)
添加图片元素
|
RectangleElement |
addRectangleElement(int x,
int y,
int width,
int height)
添加矩形元素
|
TextElement |
addTextElement(String text,
Font font,
int x,
int y)
添加文本元素
|
TextElement |
addTextElement(String text,
int fontSize,
int x,
int y)
添加文本元素
|
TextElement |
addTextElement(String text,
String fontName,
int fontSize,
int x,
int y)
添加文本元素
|
BufferedImage |
combine()
合成图片,返回图片对象
|
BufferedImage |
getCombinedImage()
获取合成后的图片对象
|
InputStream |
getCombinedImageStream()
获取合成后的图片流
|
void |
save(String filePath)
保存合成后的图片
|
void |
setBackgroundBlur(int blur)
设置背景高斯模糊(毛玻璃效果)
|
void |
setCanvasRoundCorner(Integer roundCorner)
设置画布圆角(针对整图)
|
public ImageCombiner(int canvasWidth,
int canvasHeight,
OutputFormat outputFormat)
canvasWidth - 画布宽canvasHeight - 画布高outputFormat - 输出图片格式public ImageCombiner(int canvasWidth,
int canvasHeight,
Color bgColor,
OutputFormat outputFormat)
canvasWidth - 画布宽canvasHeight - 画布高bgColor - 画布颜色(如果需要透明背景,不要设这个参数,比方图片边缘是圆角的场景)outputFormat - 输出图片格式public ImageCombiner(String bgImageUrl, OutputFormat outputFormat) throws Exception
bgImageUrl - 背景图片地址(画布以背景图宽高为基准)outputFormat - 输出图片格式Exceptionpublic ImageCombiner(BufferedImage bgImage, OutputFormat outputFormat)
bgImage - 背景图片对象(画布以背景图宽高为基准)outputFormat - 输出图片格式Exceptionpublic ImageCombiner(String bgImageUrl, int width, int height, ZoomMode zoomMode, OutputFormat outputFormat) throws Exception
bgImageUrl - 背景图片地址width - 背景图宽度height - 背景图高度zoomMode - 缩放模式outputFormat - 输出图片格式Exceptionpublic ImageCombiner(BufferedImage bgImage, int width, int height, ZoomMode zoomMode, OutputFormat outputFormat)
bgImage - 背景图片对象width - 背景图宽度height - 背景图高度zoomMode - 缩放模式outputFormat - 输出图片格式public BufferedImage combine() throws Exception
Exceptionpublic void setBackgroundBlur(int blur)
public void setCanvasRoundCorner(Integer roundCorner) throws Exception
roundCorner - Exceptionpublic BufferedImage getCombinedImage()
public InputStream getCombinedImageStream() throws Exception
Exceptionpublic void save(String filePath) throws Exception
filePath - 完整保存路径,如 “d://123.jpg”IOExceptionExceptionpublic void addElement(CombineElement element)
element - 图片或文本元素public ImageElement addImageElement(String imgUrl, int x, int y) throws Exception
imgUrl - 图片urlx - x坐标y - y坐标Exceptionpublic ImageElement addImageElement(BufferedImage image, int x, int y)
image - 图片对象x - x坐标y - y坐标public ImageElement addImageElement(String imgUrl, int x, int y, int width, int height, ZoomMode zoomMode)
imgUrl - 图片rulx - x坐标y - y坐标width - 宽度height - 高度zoomMode - 缩放模式public ImageElement addImageElement(BufferedImage image, int x, int y, int width, int height, ZoomMode zoomMode)
image - 图片对象x - x坐标y - y坐标width - 宽度height - 高度zoomMode - 缩放模式public TextElement addTextElement(String text, Font font, int x, int y)
text - 文本font - Font对象x - x坐标y - y坐标public TextElement addTextElement(String text, int fontSize, int x, int y)
text - 文本fontSize - 字体大小x - x坐标y - y坐标public TextElement addTextElement(String text, String fontName, int fontSize, int x, int y)
text - 文本fontName - 字体名称fontSize - 字体大小x - x坐标y - y坐标public RectangleElement addRectangleElement(int x, int y, int width, int height)
x - x坐标y - y坐标width - 宽度height - 高度Copyright © 2021. All rights reserved.