java.lang.Object
com.tlcsdm.core.javafx.util.ImgToolUtil
图片处理
new Img("pic/1.jpg").thumbnail(100,100).save("pic/1_thumb.jpg");
new Img("pic/1.jpg").resize(100,100).save("pic/1_scale.jpg");
new Img("pic/1.jpg").corner(1.0f).save("pic/1_corner.jpg");//0~1.0f,1.0相当于变成圆形
new Img("pic/1.jpg").square().save("pic/1_square.jpg");
new Img("pic/1.jpg").rotate(45).save("pic/1_rotate.jpg");
new Img("pic/1.jpg").draw("pic/logo.jpg").save("pic/1_logo.jpg");
new Img("img/2.jpg").corner(1.0f).thumbnail(50, 50).save("img/2_50.jpg").corner().save("img/2_50_round.jpg");
- 作者:
- unknowIfGuestInDream
-
嵌套类概要
嵌套类 -
字段概要
字段 -
构造器概要
构造器限定符构造器说明protectedImgToolUtil(BufferedImage image) ImgToolUtil(InputStream path) ImgToolUtil(InputStream path, String type) ImgToolUtil(String path) -
方法概要
修饰符和类型方法说明private static double[]calculatePosition(double x, double y, double angle) corner()图片处理成圆角corner(float percent) 图片处理成圆角corner(int radius) 图片处理成圆角protected static BufferedImagecornerImp(BufferedImage image, int radius) 制作圆角图片(适合圆角头像啥的)cut(int x, int y, int width, int height) 图片剪切draw(BufferedImage img) draw(BufferedImage img, ImgToolUtil.Align align) draw(BufferedImage img, ImgToolUtil.Align align, int offset) draw(BufferedImage img, ImgToolUtil.Align align, Double degree) draw(BufferedImage img, ImgToolUtil.Align align, Double degree, int offset, float alpha) draw(BufferedImage img, ImgToolUtil.Align align, Double degree, int offsetX, int offsetY, float alpha) 绘制图片水印draw(String imgPath, ImgToolUtil.Align align) draw(String imgPath, ImgToolUtil.Align align, Double degree, int offsetX, int offsetY, float alpha) protected voidprotected static BufferedImagedrawIcon(BufferedImage image, Image icon, int x, int y, Float alpha) flip(boolean isHorizontal) 反转static ColorgetAwtColor(javafx.scene.paint.Color color) getImage()protected AffineTransformOpgetTransformOp(boolean isHorizontal) getType()intheight()static Imagebooleanprivate static booleanprotected static InputStreamstatic javafx.scene.image.ImagepixWithImage(int type, javafx.scene.image.Image image) 根据传入类型变化图片像素resize(int size) 拉伸到目标尺寸resize(int width, int height) 拉伸到目标大小protected static BufferedImageresizeImp(BufferedImage source, int width, int height, boolean ratioKeep) 生成缩略图rotate(double degree) 对图片进行旋转protected static BufferedImagerotateImp(BufferedImage image, double angle) save(OutputStream path) save(OutputStream path, String format) voidsetAlphaed(boolean alphaed) voidsetImage(BufferedImage image) voidsquare()将图片变成方形(默认以最小边为准)square(boolean small) 将图片变为方形thumbnail(int size) 缩略图到目标尺寸thumbnail(int width, int height) 缩略图到目标大小intwidth()
-
字段详细资料
-
image
-
type
-
alphaed
protected boolean alphaed
-
-
构造器详细资料
-
ImgToolUtil
protected ImgToolUtil() -
ImgToolUtil
- 抛出:
IOException
-
ImgToolUtil
- 抛出:
IOException
-
ImgToolUtil
- 抛出:
IOException
-
ImgToolUtil
- 抛出:
IOException
-
-
方法详细资料
-
open
- 抛出:
IOException
-
width
public int width() -
height
public int height() -
flip
反转- 参数:
isHorizontal-- 返回:
-
getTransformOp
-
resize
拉伸到目标尺寸- 参数:
size-- 返回:
-
resize
拉伸到目标大小- 参数:
width-height-- 返回:
-
thumbnail
缩略图到目标尺寸 -
thumbnail
缩略图到目标大小- 参数:
width-height-- 返回:
-
square
将图片变成方形(默认以最小边为准) -
square
将图片变为方形- 参数:
small-- 返回:
-
corner
图片处理成圆角- 参数:
radius- 圆角尺寸,比如填10表示10px- 返回:
-
corner
图片处理成圆角- 返回:
-
corner
图片处理成圆角- 参数:
percent- 圆角比例- 返回:
-
cut
图片剪切- 参数:
x-y-width-height-- 返回:
-
save
- 抛出:
IOException
-
save
- 抛出:
IOException
-
save
- 抛出:
IOException
-
save
- 抛出:
IOException
-
rotate
对图片进行旋转- 参数:
degree- 0-360- 返回:
-
calculatePosition
private static double[] calculatePosition(double x, double y, double angle) -
rotateImp
-
draw
-
draw
-
draw
-
draw
-
draw
public ImgToolUtil draw(BufferedImage img, ImgToolUtil.Align align, Double degree, int offset, float alpha) -
draw
- 抛出:
IOException
-
draw
- 抛出:
IOException
-
draw
public ImgToolUtil draw(String imgPath, ImgToolUtil.Align align, Double degree, int offsetX, int offsetY, float alpha) throws IOException - 抛出:
IOException
-
draw
public ImgToolUtil draw(BufferedImage img, ImgToolUtil.Align align, Double degree, int offsetX, int offsetY, float alpha) 绘制图片水印- 参数:
img- 图片align- 位置degree- 旋转角度offsetX- 偏移xoffsetY- 偏移yalpha- 透明度- 返回:
-
drawApply
-
icon
-
drawIcon
-
cornerImp
制作圆角图片(适合圆角头像啥的)- 参数:
image-radius- 圆角尺寸- 返回:
-
resizeImp
protected static BufferedImage resizeImp(BufferedImage source, int width, int height, boolean ratioKeep) 生成缩略图- 参数:
source-width- 目标宽度height- 目标高度ratioKeep- 是否等比缩放- 返回:
-
isUrlPath
-
getImage
-
setImage
-
getType
-
setType
-
isAlphaed
public boolean isAlphaed() -
setAlphaed
public void setAlphaed(boolean alphaed) -
pixWithImage
public static javafx.scene.image.Image pixWithImage(int type, javafx.scene.image.Image image) 根据传入类型变化图片像素 -
getAwtColor
-