public class OperateImage extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
IMAGE_TYPE_BMP |
static String |
IMAGE_TYPE_GIF |
static String |
IMAGE_TYPE_JPEG |
static String |
IMAGE_TYPE_JPG |
static String |
IMAGE_TYPE_PNG |
static String |
IMAGE_TYPE_PSD |
| 构造器和说明 |
|---|
OperateImage() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
alphaImage2Image(String srcImagePath,
String appendImagePath,
float alpha,
int x,
int y,
int width,
int height,
String imageFormat,
String toPath)
在源图像上设置图片水印
---- 当alpha==1时文字不透明(和在图片上直接输入文字效果一样)
|
static void |
alphaWords2Image(String srcImagePath,
float alpha,
String font,
int fontStyle,
int fontSize,
Color color,
String inputWords,
int x,
int y,
String imageFormat,
String toPath)
在源图片上设置水印文字
|
static void |
cropImage(String srcPath,
String toPath,
int x,
int y,
int width,
int height,
String readImageFormat,
String writeImageFormat)
对图片裁剪,并把裁剪新图片保存
|
static void |
drawAndAlphaPolygon(String srcImagePath,
int[] xPoints,
int[] yPoints,
int nPoints,
Color polygonColor,
float alpha,
String imageFormat,
String toPath)
绘制并填充多边形
|
static void |
drawLine(String srcImagePath,
int x1,
int y1,
int x2,
int y2,
Color lineColor,
String toPath,
String imageFormat)
画线段
|
static void |
drawPoint(String srcImagePath,
int x,
int y,
int width,
int height,
Color ovalColor,
String imageFormat,
String toPath)
画单点 ---- 实际上是画一个填充颜色的圆
---- 以指定点坐标为中心画一个小半径的圆形,并填充其颜色来充当点
|
static void |
drawPoints(String srcImagePath,
List pointList,
int width,
int height,
Color ovalColor,
String imageFormat,
String toPath)
画一组(多个)点---- 实际上是画一组(多个)填充颜色的圆
---- 以指定点坐标为中心画一个小半径的圆形,并填充其颜色来充当点
|
static void |
drawPolygon(String srcImagePath,
int[] xPoints,
int[] yPoints,
int nPoints,
Color polygonColor,
String imageFormat,
String toPath)
绘制一个由 x 和 y 坐标数组定义的闭合多边形
|
static void |
drawPolyline(String srcImagePath,
int[] xPoints,
int[] yPoints,
int nPoints,
Color lineColor,
String toPath,
String imageFormat)
画折线 / 线段
---- 2个点即画线段,多个点画折线
|
static void |
drawPolylineShowPoints(String srcImagePath,
int[] xPoints,
int[] yPoints,
int nPoints,
Color lineColor,
int width,
int height,
Color ovalColor,
String toPath,
String imageFormat)
绘制折线,并突出显示转折点
|
static void |
enlargementImageByRatio(String srcImagePath,
String toImagePath,
int widthRatio,
int heightRatio)
按倍率放大图片
|
static void |
enlargementImageEqualProportion(String srcImagePath,
String toImagePath,
int ratio)
长高等比例放大图片
|
static void |
grayImage(String srcImage,
String toPath,
String imageFormat)
图片灰化操作
|
static boolean |
joinImageListHorizontal(String[] pics,
String type,
String dst_pic)
横向拼接一组(多张)图像
|
static boolean |
joinImageListVertical(String[] pics,
String type,
String dst_pic)
纵向拼接一组(多张)图像
|
static void |
joinImagesHorizontal(String firstSrcImagePath,
String secondSrcImagePath,
String imageFormat,
String toPath)
横向拼接图片(两张)
|
static void |
joinImagesVertical(String firstSrcImagePath,
String secondSrcImagePath,
String imageFormat,
String toPath)
纵向拼接图片(两张)
|
static void |
mergeBothImage(String negativeImagePath,
String additionImagePath,
String iamgeFromat,
int x,
int y,
String toPath)
合并图片(按指定初始x、y坐标将附加图片贴到底图之上)
|
static void |
mergeImageList(String negativeImagePath,
List additionImageList,
String imageFormat,
String toPath)
将一组图片一次性附加合并到底图上
|
static void |
reduceImageByRatio(String srcImagePath,
String toImagePath,
int widthRatio,
int heightRatio)
按倍率缩小图片
|
static void |
reduceImageEqualProportion(String srcImagePath,
String toImagePath,
int ratio)
长高等比例缩小图片
|
static void |
resizeImage(String srcImagePath,
String toImagePath,
int width,
int height)
重置图形的边长大小
|
public static String IMAGE_TYPE_GIF
public static String IMAGE_TYPE_JPG
public static String IMAGE_TYPE_JPEG
public static String IMAGE_TYPE_BMP
public static String IMAGE_TYPE_PNG
public static String IMAGE_TYPE_PSD
public static void cropImage(String srcPath, String toPath, int x, int y, int width, int height, String readImageFormat, String writeImageFormat) throws IOException
srcPath - 读取源图片路径toPath - 写入图片路径x - 剪切起始点x坐标y - 剪切起始点y坐标width - 剪切宽度height - 剪切高度readImageFormat - 读取图片格式writeImageFormat - 写入图片格式IOExceptionpublic static void reduceImageByRatio(String srcImagePath, String toImagePath, int widthRatio, int heightRatio) throws IOException
srcImagePath - 读取图片路径toImagePath - 写入图片路径widthRatio - 宽度缩小比例heightRatio - 高度缩小比例IOExceptionpublic static void reduceImageEqualProportion(String srcImagePath, String toImagePath, int ratio) throws IOException
srcImagePath - 读取图片路径toImagePath - 写入图片路径ratio - 缩小比例IOExceptionpublic static void enlargementImageByRatio(String srcImagePath, String toImagePath, int widthRatio, int heightRatio) throws IOException
srcImagePath - 读取图形路径toImagePath - 写入入行路径widthRatio - 宽度放大比例heightRatio - 高度放大比例IOExceptionpublic static void enlargementImageEqualProportion(String srcImagePath, String toImagePath, int ratio) throws IOException
srcImagePath - 读取图形路径toImagePath - 写入入行路径ratio - 放大比例IOExceptionpublic static void resizeImage(String srcImagePath, String toImagePath, int width, int height) throws IOException
srcImagePath - 原图像toImagePath - 新生产的图像width - 图像宽度height - 图像高度IOExceptionpublic static void joinImagesHorizontal(String firstSrcImagePath, String secondSrcImagePath, String imageFormat, String toPath)
firstSrcImagePath - 第一张图片的路径secondSrcImagePath - 第二张图片的路径imageFormat - 拼接生成图片的格式toPath - 拼接生成图片的路径
要拼接的俩张图片尺寸要一致public static boolean joinImageListHorizontal(String[] pics, String type, String dst_pic)
pics - 将要拼接的图像type - 图像写入格式dst_pic - 图像写入路径public static void joinImagesVertical(String firstSrcImagePath, String secondSrcImagePath, String imageFormat, String toPath)
firstSrcImagePath - 读取的第一张图片secondSrcImagePath - 读取的第二张图片imageFormat - 图片写入格式toPath - 图片写入路径public static boolean joinImageListVertical(String[] pics, String type, String dst_pic)
pics - 将要拼接的图像数组type - 写入图像类型dst_pic - 写入图像路径public static void mergeBothImage(String negativeImagePath, String additionImagePath, String iamgeFromat, int x, int y, String toPath) throws IOException
negativeImagePath - 背景图片路径additionImagePath - 附加图片路径x - 附加图片的起始点x坐标y - 附加图片的起始点y坐标toPath - 图片写入路径IOExceptionpublic static void mergeImageList(String negativeImagePath, List additionImageList, String imageFormat, String toPath) throws IOException
negativeImagePath - 源图像(底图)路径additionImageList - 附加图像信息列表imageFormat - 图像写入格式toPath - 图像写入路径IOExceptionpublic static void grayImage(String srcImage, String toPath, String imageFormat)
srcImage - 读取图片路径toPath - 写入灰化后的图片路径imageFormat - 图片写入格式public static void alphaWords2Image(String srcImagePath, float alpha, String font, int fontStyle, int fontSize, Color color, String inputWords, int x, int y, String imageFormat, String toPath) throws IOException
srcImagePath - 源图片路径alpha - 透明度(0font - 字体(例如:宋体)fontStyle - 字体格式(例如:普通样式--Font.PLAIN、粗体--Font.BOLD )fontSize - 字体大小color - 字体颜色(例如:黑色--Color.BLACK)inputWords - 输入显示在图片上的文字x - 文字显示起始的x坐标y - 文字显示起始的y坐标imageFormat - 写入图片格式(png/jpg等)toPath - 写入图片路径IOExceptionpublic static void alphaImage2Image(String srcImagePath, String appendImagePath, float alpha, int x, int y, int width, int height, String imageFormat, String toPath) throws IOException
srcImagePath - 源图片路径appendImagePath - 水印图片路径alpha - 透明度x - 水印图片的起始x坐标y - 水印图片的起始y坐标width - 水印图片的宽度height - 水印图片的高度imageFormat - 图像写入图片格式toPath - 图像写入路径IOExceptionpublic static void drawPoint(String srcImagePath, int x, int y, int width, int height, Color ovalColor, String imageFormat, String toPath) throws IOException
srcImagePath - 源图片颜色x - 点的x坐标y - 点的y坐标width - 填充的宽度height - 填充的高度ovalColor - 填充颜色imageFormat - 写入图片格式toPath - 写入路径IOExceptionpublic static void drawPoints(String srcImagePath, List pointList, int width, int height, Color ovalColor, String imageFormat, String toPath) throws IOException
srcImagePath - 原图片路径pointList - 点列表width - 宽度height - 高度ovalColor - 填充颜色imageFormat - 写入图片颜色toPath - 写入路径IOExceptionpublic static void drawLine(String srcImagePath, int x1, int y1, int x2, int y2, Color lineColor, String toPath, String imageFormat) throws IOException
srcImagePath - 源图片路径x1 - 第一个点x坐标y1 - 第一个点y坐标x2 - 第二个点x坐标y2 - 第二个点y坐标lineColor - 线条颜色toPath - 图像写入路径imageFormat - 图像写入格式IOExceptionpublic static void drawPolyline(String srcImagePath, int[] xPoints, int[] yPoints, int nPoints, Color lineColor, String toPath, String imageFormat) throws IOException
srcImagePath - 源图片路径xPoints - x坐标数组yPoints - y坐标数组nPoints - 点的数量lineColor - 线条颜色toPath - 图像写入路径imageFormat - 图片写入格式IOExceptionpublic static void drawPolylineShowPoints(String srcImagePath, int[] xPoints, int[] yPoints, int nPoints, Color lineColor, int width, int height, Color ovalColor, String toPath, String imageFormat) throws IOException
srcImagePath - 源图片路径xPoints - x坐标数组yPoints - y坐标数组nPoints - 点的数量lineColor - 连线颜色width - 点的宽度height - 点的高度ovalColor - 点的填充颜色toPath - 图像写入路径imageFormat - 图像写入格式IOExceptionpublic static void drawPolygon(String srcImagePath, int[] xPoints, int[] yPoints, int nPoints, Color polygonColor, String imageFormat, String toPath) throws IOException
srcImagePath - 源图片路径xPoints - x坐标数组yPoints - y坐标数组nPoints - 坐标点的个数polygonColor - 线条颜色imageFormat - 图像写入格式toPath - 图像写入路径IOExceptionpublic static void drawAndAlphaPolygon(String srcImagePath, int[] xPoints, int[] yPoints, int nPoints, Color polygonColor, float alpha, String imageFormat, String toPath) throws IOException
srcImagePath - 源图像路径xPoints - x坐标数组yPoints - y坐标数组nPoints - 坐标点个数polygonColor - 多边形填充颜色alpha - 多边形部分透明度imageFormat - 写入图形格式toPath - 写入图形路径IOExceptionCopyright © 2016. All rights reserved.