public class Images extends Object
构造器和说明 |
---|
Images() |
限定符和类型 | 方法和说明 |
---|---|
static BufferedImage |
clipScale(BufferedImage im,
int w,
int h)
自动缩放剪切一个图片,令其符合给定的尺寸
如果图片太大,则将其缩小,如果图片太小,则将其放大,多余的部分被裁减
|
static BufferedImage |
clipScale(Object srcIm,
File taIm,
int[] startPoint,
int[] endPoint)
根据给定的起始坐标点与结束坐标点来剪切一个图片,令其符合给定的尺寸,并将其保存成目标图像文件
图片格式支持 png | gif | jpg | bmp | wbmp
|
static BufferedImage |
clipScale(Object srcIm,
File taIm,
int w,
int h)
自动缩放剪切一个图片,令其符合给定的尺寸,并将其保存成目标图像文件
图片格式支持 png | gif | jpg | bmp | wbmp
|
static BufferedImage |
clipScale(Object srcIm,
int[] startPoint,
int[] endPoint) |
static BufferedImage |
clipScale(String srcPath,
String taPath,
int[] startPoint,
int[] endPoint)
根据给定的起始坐标点与结束坐标点来剪切一个图片,令其符合给定的尺寸,并将其保存成目标图像文件
图片格式支持 png | gif | jpg | bmp | wbmp
|
static BufferedImage |
clipScale(String srcPath,
String taPath,
int w,
int h)
自动缩放剪切一个图片,令其符合给定的尺寸,并将其保存到目标图像路径
图片格式支持 png | gif | jpg | bmp | wbmp
|
static String |
encodeBase64(File targetFile)
生成该图片对应的 Base64 编码的字符串
|
static String |
encodeBase64(String targetFile)
生成该图片对应的 Base64 编码的字符串
|
static BufferedImage |
read(Object img)
将一个图片文件读入内存
|
static BufferedImage |
redraw(BufferedImage img,
Color bg)
在一个RGB画布上重新绘制Image,解决CMYK图像偏色的问题
|
static BufferedImage |
rotate(BufferedImage image,
int degree)
对一个图像进行旋转
|
static BufferedImage |
rotate(Object srcIm,
File taIm,
int degree)
对一个图像进行旋转
|
static BufferedImage |
rotate(String srcPath,
String taPath,
int degree)
对一个图像进行旋转
|
static BufferedImage |
scale(BufferedImage im,
int w,
int h)
自动等比缩放一个图片
|
static void |
write(RenderedImage im,
File targetFile)
将内存中一个图片写入目标文件
|
static void |
write(RenderedImage im,
String imFormat,
OutputStream out)
将内存中的一个写入输出流
|
static void |
writeAndClose(RenderedImage im,
String imFormat,
OutputStream out) |
static void |
writeJpeg(RenderedImage im,
Object targetJpg,
float quality)
写入一个 JPG 图像
|
static BufferedImage |
zoomScale(BufferedImage im,
int w,
int h) |
static BufferedImage |
zoomScale(BufferedImage im,
int w,
int h,
Color bgColor)
自动等比缩放一个图片,多余的部分,用给定背景颜色补上
如果参数中的宽度或高度为-1的话,着按照指定的高度或宽度对原图等比例缩放图片,不添加背景颜色 |
static BufferedImage |
zoomScale(Object srcIm,
File taIm,
int w,
int h,
Color bgColor)
自动等比缩放一个图片,并将其保存成目标图像文件
多余的部分,用给定背景颜色补上 如果参数中的宽度或高度为-1的话,着按照指定的高度或宽度对原图等比例缩放图片,不添加背景颜色 图片格式支持 png | gif | jpg | bmp | wbmp |
static BufferedImage |
zoomScale(String srcPath,
String taPath,
int w,
int h,
Color bgColor)
自动等比缩放一个图片,并将其保存成目标图像文件
多余的部分,用给定背景颜色补上 如果参数中的宽度或高度为-1的话,着按照指定的高度或宽度对原图等比例缩放图片,不添加背景颜色 图片格式支持 png | gif | jpg | bmp | wbmp |
public static BufferedImage rotate(Object srcIm, File taIm, int degree)
srcIm
- 原图像文件taIm
- 转换后的图像文件degree
- 旋转角度, 90 为顺时针九十度, -90 为逆时针九十度public static BufferedImage rotate(String srcPath, String taPath, int degree) throws IOException
srcPath
- 原图像文件路径taPath
- 转换后的图像文件路径degree
- 旋转角度, 90 为顺时针九十度, -90 为逆时针九十度IOException
public static BufferedImage rotate(BufferedImage image, int degree)
image
- 图像degree
- 旋转角度, 90 为顺时针九十度, -90 为逆时针九十度public static BufferedImage zoomScale(Object srcIm, File taIm, int w, int h, Color bgColor) throws IOException
图片格式支持 png | gif | jpg | bmp | wbmp
srcIm
- 源图像文件对象taIm
- 目标图像文件对象w
- 宽度h
- 高度bgColor
- 背景颜色IOException
- 当读写文件失败时抛出public static BufferedImage zoomScale(String srcPath, String taPath, int w, int h, Color bgColor) throws IOException
图片格式支持 png | gif | jpg | bmp | wbmp
srcPath
- 源图像路径taPath
- 目标图像路径,如果不存在,则创建w
- 宽度h
- 高度bgColor
- 背景颜色IOException
- 当读写文件失败时抛出public static BufferedImage zoomScale(BufferedImage im, int w, int h, Color bgColor)
im
- 图像对象w
- 宽度h
- 高度bgColor
- 背景颜色public static BufferedImage zoomScale(BufferedImage im, int w, int h)
public static BufferedImage scale(BufferedImage im, int w, int h)
im
- 图像对象w
- 宽度h
- 高度public static BufferedImage clipScale(Object srcIm, File taIm, int w, int h) throws IOException
图片格式支持 png | gif | jpg | bmp | wbmp
srcIm
- 源图像文件对象taIm
- 目标图像文件对象w
- 宽度h
- 高度IOException
- 当读写文件失败时抛出public static BufferedImage clipScale(String srcPath, String taPath, int w, int h) throws IOException
图片格式支持 png | gif | jpg | bmp | wbmp
srcPath
- 源图像路径taPath
- 目标图像路径,如果不存在,则创建w
- 宽度h
- 高度IOException
- 当读写文件失败时抛出public static BufferedImage clipScale(Object srcIm, int[] startPoint, int[] endPoint)
public static BufferedImage clipScale(Object srcIm, File taIm, int[] startPoint, int[] endPoint) throws IOException
图片格式支持 png | gif | jpg | bmp | wbmp
srcIm
- 源图像文件对象taIm
- 目标图像文件对象startPoint
- 起始坐标点,其值[x, y]为相对原图片左上角的坐标endPoint
- 结束坐标点,其值[x, y]为相对原图片左上角的坐标IOException
- 当读写文件失败时抛出public static BufferedImage clipScale(String srcPath, String taPath, int[] startPoint, int[] endPoint) throws IOException
图片格式支持 png | gif | jpg | bmp | wbmp
srcPath
- 源图像文件对象taPath
- 目标图像文件对象startPoint
- 起始坐标点,其值[x, y]为相对原图片左上角的坐标endPoint
- 结束坐标点,其值[x, y]为相对原图片左上角的坐标IOException
- 当读写文件失败时抛出public static BufferedImage clipScale(BufferedImage im, int w, int h)
如果图片太大,则将其缩小,如果图片太小,则将其放大,多余的部分被裁减
im
- 图像对象w
- 宽度h
- 高度public static BufferedImage read(Object img)
img
- 图片文件public static void write(RenderedImage im, File targetFile)
im
- 图片对象targetFile
- 目标文件,根据其后缀,来决定写入何种图片格式public static void write(RenderedImage im, String imFormat, OutputStream out)
im
- 图片对象imFormat
- 图片格式out
- 输出流public static void writeAndClose(RenderedImage im, String imFormat, OutputStream out)
public static void writeJpeg(RenderedImage im, Object targetJpg, float quality)
im
- 图像对象targetJpg
- 目标输出 JPG 图像文件quality
- 质量 0.1f ~ 1.0fpublic static String encodeBase64(String targetFile)
targetFile
- 图片文件public static String encodeBase64(File targetFile)
targetFile
- 图片文件public static BufferedImage redraw(BufferedImage img, Color bg)
Copyright © 2017. All rights reserved.