public class Images extends Object
Modifier and Type | Method and Description |
---|---|
static byte[] |
base64Decode(String s)
图片 base64 解码
|
static String |
base64Encode(BufferedImage img)
BufferedImage 转 base64
|
static String |
base64Encode(BufferedImage img,
String format)
BufferedImage 转 base64
|
static String |
base64Encode(byte[] bs)
图片 base64 编码
|
static String |
base64Encode(byte[] bs,
String type)
图片 base64 编码
|
static BufferedImage |
copy(BufferedImage img)
复制 BufferedImage
|
static BufferedImage |
copy(BufferedImage img,
int imageType)
复制 BufferedImage
|
static byte[] |
getBytes(BufferedImage img)
BufferedImage 转 byte[]
|
static byte[] |
getBytes(BufferedImage img,
String format)
BufferedImage 转 byte[]
|
static BufferedImage |
getImage(byte[] bs)
获取BufferedImage
|
static BufferedImage |
getImage(File file)
获取BufferedImage
|
static BufferedImage |
getImage(InputStream in)
获取BufferedImage
|
static BufferedImage |
getImage(String path)
获取 BufferedImage
|
static BufferedImage |
getImageBase64(byte[] bs)
获取BufferedImage
|
static BufferedImage |
getImageBase64(String base64)
获取BufferedImage
|
static BufferedImage |
getImageByIcons(byte[] bs) |
static BufferedImage |
getImageByIcons(ImageIcon icon)
通过 ImageIcon 获取图片 解决读取文件是红色遮罩层的问题
|
static BufferedImage |
getImageByIcons(InputStream in) |
static BufferedImage |
getImageByIcons(String base64) |
static BufferedImage |
getRadiusImage(BufferedImage image,
float arcw,
float arch)
绘制圆角
|
static BufferedImage |
getRadiusImage(BufferedImage image,
int radius) |
static int[] |
getSize(BufferedImage img)
获取图片大小
|
static BufferedImage |
getTransparentImage(int width,
int height)
创建一个透明背景的图片 需要png格式导出
|
static BufferedImage |
resize(BufferedImage img,
int width,
int height)
重置图片大小
|
static BufferedImage |
resize(BufferedImage img,
int width,
int height,
int x,
int y)
重置图片大小
|
static void |
setAntiAliasing(Graphics2D g2d)
设置抗锯齿
|
static void |
write(BufferedImage img,
File file)
BufferedImage 输出到文件
|
static void |
write(BufferedImage img,
OutputStream out)
BufferedImage 输出到流
|
static void |
write(BufferedImage img,
String path)
BufferedImage 输出到文件
|
static void |
write(BufferedImage img,
String format,
File file)
BufferedImage 输出到文件
|
static void |
write(BufferedImage img,
String format,
OutputStream out)
BufferedImage 输出到流
|
static void |
write(BufferedImage img,
String format,
String path)
BufferedImage 输出到文件
|
public static BufferedImage copy(BufferedImage img)
img
- BufferedImagepublic static BufferedImage copy(BufferedImage img, int imageType)
img
- BufferedImageimageType
- 图片类型public static BufferedImage resize(BufferedImage img, int width, int height)
img
- 图片width
- 新宽度height
- 新高度public static BufferedImage resize(BufferedImage img, int width, int height, int x, int y)
img
- 图片width
- 新宽度height
- 新高度x
- 绘制x坐标y
- 绘制y坐标public static void setAntiAliasing(Graphics2D g2d)
g2d
- g2dpublic static BufferedImage getTransparentImage(int width, int height)
width
- widthheight
- heightpublic static BufferedImage getRadiusImage(BufferedImage image, int radius)
public static BufferedImage getRadiusImage(BufferedImage image, float arcw, float arch)
image
- imagearcw
- arcwarch
- archpublic static BufferedImage getImage(String path)
path
- 文件路径public static BufferedImage getImage(File file)
file
- 文件public static BufferedImage getImage(byte[] bs)
bs
- bytespublic static BufferedImage getImage(InputStream in)
in
- inputStreampublic static BufferedImage getImageBase64(String base64)
base64
- base64 包含头public static BufferedImage getImageBase64(byte[] bs)
bs
- base64bytes 不包含头public static BufferedImage getImageByIcons(byte[] bs)
public static BufferedImage getImageByIcons(InputStream in) throws IOException
IOException
public static BufferedImage getImageByIcons(String base64)
public static BufferedImage getImageByIcons(ImageIcon icon)
icon
- iconpublic static int[] getSize(BufferedImage img)
img
- 图片public static byte[] getBytes(BufferedImage img)
img
- imgpublic static byte[] getBytes(BufferedImage img, String format)
img
- imgformat
- 格式public static void write(BufferedImage img, OutputStream out) throws IOException
img
- imageout
- 输出流IOException
- IOExceptionpublic static void write(BufferedImage img, String format, OutputStream out) throws IOException
img
- imageformat
- 格式out
- 输出流IOException
- IOExceptionpublic static void write(BufferedImage img, String path) throws IOException
img
- imagepath
- 文件路径IOException
- IOExceptionpublic static void write(BufferedImage img, String format, String path) throws IOException
img
- imageformat
- 格式path
- 文件路径IOException
- IOExceptionpublic static void write(BufferedImage img, File file) throws IOException
img
- imagefile
- 文件IOException
- IOExceptionpublic static void write(BufferedImage img, String format, File file) throws IOException
img
- imageformat
- 格式file
- 文件IOException
- IOExceptionpublic static String base64Encode(BufferedImage img)
img
- imgpublic static String base64Encode(BufferedImage img, String format)
img
- imgformat
- 格式public static String base64Encode(byte[] bs)
bs
- bspublic static String base64Encode(byte[] bs, String type)
bs
- bstype
- jpg, jpeg, pngpublic static byte[] base64Decode(String s)
s
- base64Copyright © 2024. All rights reserved.