public class LazyImage extends BaseLazyImage implements ImageMatrix
open()
可以在不将图像全部解码加载到内存而获取图像的基本信息read(ImageReadParam)
使用内存做cache读取(不使用临时文件做cache)read(Rectangle, ImageTypeSpecifier)
可以对图像指定区域解码autoClose, height, imgBytes, localFile, matrixBGR, matrixGray, matrixRGB, matrixRGBA, md5, suffix, width
Constructor and Description |
---|
LazyImage(java.awt.image.BufferedImage bufferedImage) |
LazyImage(byte[] imgBytes) |
LazyImage(java.io.File src,
java.lang.String md5)
用本地图像文件创建对象
|
LazyImage(T src)
多源创建对象
|
Modifier and Type | Method and Description |
---|---|
void |
close()
释放资源
|
static LazyImage |
create(java.awt.image.BufferedImage bufferedImage)
创建对象
|
static LazyImage |
create(byte[] imgBytes)
创建并打开对象
|
static LazyImage |
create(java.io.File file,
java.lang.String md5)
用本地图像文件创建对象
|
static <T> LazyImage |
create(T src)
多源创建对象
|
void |
finalize() |
byte[] |
getMatrixBGR()
对图像解码返回BGR格式矩阵数据
|
byte[] |
getMatrixGray()
对图像数据指定的区域解码返回灰度图像数据
|
byte[] |
getMatrixRGB()
对图像解码返回RGB格式矩阵数据
|
byte[] |
getMatrixRGBA()
对图像解码返回RGBA格式矩阵数据
|
java.awt.Rectangle |
getRectangle()
获取图像矩形对象
|
LazyImage |
open()
通过
ImageReader 来读取图像基本信息,检查图像数据有效性 |
java.awt.image.BufferedImage |
read() |
protected java.awt.image.BufferedImage |
read(javax.imageio.ImageReadParam param)
对图像数据解码生成
BufferedImage 对象 |
java.awt.image.BufferedImage |
read(java.awt.Rectangle rect,
javax.imageio.ImageTypeSpecifier destinationType)
对图像数据指定的区域解码
|
byte[] |
wirteJPEGBytes() |
byte[] |
wirtePNGBytes() |
getHeight, getImgBytes, getLazyImageFactory, getLocalFile, getMd5, getSuffix, getWidth, save, setAutoClose, wirteJPEG, wirtePNGB
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getHeight, getWidth
public LazyImage(java.awt.image.BufferedImage bufferedImage)
bufferedImage
- 已经解码的图像数据,为null或为空,则抛出 IllegalArgumentException
public LazyImage(byte[] imgBytes)
imgBytes
- 图像数据,imgBytes
为null或为空,则抛出 IllegalArgumentException
public LazyImage(java.io.File src, java.lang.String md5) throws java.io.FileNotFoundException
src
- md5
- java.io.FileNotFoundException
public LazyImage(T src) throws java.io.IOException
src
- java.io.IOException
FaceUtilits.getBytesNotEmpty(Object)
public LazyImage open() throws UnsupportedFormatException, NotImageException
ImageReader
来读取图像基本信息,检查图像数据有效性open
in class BaseLazyImage
UnsupportedFormatException
NotImageException
protected java.awt.image.BufferedImage read(javax.imageio.ImageReadParam param) throws UnsupportedFormatException
BufferedImage
对象param
- 图像读取参数对象,为null使用默认参数ImageReader.getDefaultReadParam()
UnsupportedFormatException
ImageReadParam
public java.awt.image.BufferedImage read() throws UnsupportedFormatException
UnsupportedFormatException
public java.awt.image.BufferedImage read(java.awt.Rectangle rect, javax.imageio.ImageTypeSpecifier destinationType) throws UnsupportedFormatException
rect
- 解码区域对象, 默认(null
)全图解码IIOParam.setSourceRegion(Rectangle)
destinationType
- 目标图像的所需图像类型,默认为null, ImageTypeSpecifier destinationType=ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_3BYTE_BGR);
ImageReadParam.setDestinationType(ImageTypeSpecifier)
UnsupportedFormatException
read(ImageReadParam)
public byte[] getMatrixRGBA() throws UnsupportedFormatException
ImageMatrix
getMatrixRGBA
in interface ImageMatrix
UnsupportedFormatException
public byte[] getMatrixRGB() throws UnsupportedFormatException
ImageMatrix
getMatrixRGB
in interface ImageMatrix
UnsupportedFormatException
public byte[] getMatrixBGR() throws UnsupportedFormatException
ImageMatrix
getMatrixBGR
in interface ImageMatrix
UnsupportedFormatException
public byte[] getMatrixGray() throws UnsupportedFormatException
getMatrixGray
in interface ImageMatrix
UnsupportedFormatException
public byte[] wirtePNGBytes()
wirtePNGBytes
in class BaseLazyImage
public byte[] wirteJPEGBytes()
wirteJPEGBytes
in class BaseLazyImage
public static LazyImage create(byte[] imgBytes) throws NotImageException, UnsupportedFormatException
imgBytes
- NotImageException
UnsupportedFormatException
LazyImage(byte[])
,
open()
public static LazyImage create(java.awt.image.BufferedImage bufferedImage)
bufferedImage
- LazyImage(BufferedImage)
,
open()
public static LazyImage create(java.io.File file, java.lang.String md5) throws NotImageException, UnsupportedFormatException
file
- md5
- file
的MD5较验码,可以为nullNotImageException
UnsupportedFormatException
public static <T> LazyImage create(T src) throws NotImageException, UnsupportedFormatException
src
- NotImageException
UnsupportedFormatException
LazyImage(Object)
,
FaceUtilits.getBytesNotEmpty(Object)
public void close() throws java.io.IOException
close
in class BaseLazyImage
java.io.IOException
public void finalize() throws java.lang.Throwable
finalize
in class BaseLazyImage
java.lang.Throwable
public java.awt.Rectangle getRectangle()
Copyright © 2019. All rights reserved.