public class DocumentImage
extends java.lang.Object
implements java.lang.AutoCloseable, java.io.Serializable
| Constructor and Description |
|---|
DocumentImage()
Creates a new instance of the DocumentImage class.
|
DocumentImage(long handle)
Creates a new instance of the DocumentImage class.
|
| Modifier and Type | Method and Description |
|---|---|
DocumentImage |
clone()
Creates a copy of the DocumentImage object.
|
void |
close()
Releases all resources used by this DocumentImage.
|
float |
compare(DocumentImage cmpDocumentImage)
Computes the difference with another image.
|
void |
correctGamma(int contrast,
int brightness,
float gamma)
Applies a gamma correction to the image.
|
DocumentImage |
crop(int left,
int top,
int width,
int height)
Crop a rectangular region of interest in the image according to the given bounds.
|
float |
downscale(int maxSize)
Downscales the image in-place so that its maximum dimension is equal to the given maximum size, while preserving the aspect ratio.
|
float |
downscaleTo(DocumentImage dstDocumentImage,
int maxSize)
Downscales the image so that its maximum dimension equals the given maximum size, while preserving the aspect ratio.
|
DocumentImage |
extractRoi(Rectangle bounds)
Extracts a region of interest in the image according to the given bounds.
|
DocumentImage |
extractRoiWithColor(Rectangle bounds,
int colorRed,
int colorGreen,
int colorBlue)
Extracts a region of interest in the image according to the given bounds.
|
protected void |
finalize()
Finalizer for this class.
|
void |
flip(boolean flipHorizontally,
boolean flipVertically)
Flips the image in-place.
|
void |
flipTo(boolean flipHorizontally,
boolean flipVertically,
DocumentImage dstDocumentImage)
Flips the image.
|
static DocumentImage |
fromBuffer(byte[] data,
PixelFormat pixelFormat)
Creates an Image from the specified data buffer.
|
static DocumentImage |
fromFile(java.lang.String filepath,
PixelFormat pixelFormat)
Creates an Image from the specified file.
|
static DocumentImage |
fromRawBuffer(byte[] pixels,
int width,
int height,
int stride,
PixelFormat srcPixelFormat,
PixelFormat dstPixelFormat)
Creates an Image from the specified raw data buffer.
|
static DocumentImage |
fromYuvPlanes(byte[] yPlane,
byte[] uPlane,
byte[] vPlane,
int yWidth,
int yHeight,
int uvPixelStride,
int uvRowStride,
PixelFormat dstPixelFormat)
Creates an Image from the specified YUV planes.
|
byte[] |
getData()
Gets the raw data buffer of the image.
|
long |
getHandle()
Gets the native handle.
|
int |
getHeight()
Gets the height in pixels.
|
int |
getPixelDepth()
Gets the pixel depth.
|
PixelFormat |
getPixelFormat()
Gets the pixel format.
|
int |
getStride()
Gets the stride in bytes.
|
int |
getWidth()
Gets the width in pixels.
|
void |
pad(int top,
int left,
int bottom,
int right,
int colorRed,
int colorGreen,
int colorBlue)
Add padding around the image
Only works for BGR 24 bits, RGB 24 bits and Grayscale 8bits images.
|
void |
reallocate(int width,
int height,
PixelFormat pixelFormat)
Reallocates the internal memory of the Image from parameters.
|
void |
resize(int width,
int height)
Resizes the image in-place to the required width and height.
|
void |
resizeTo(int width,
int height,
DocumentImage dstDocumentImage)
Resizes the image to the specified width and height.
|
void |
rotate(int angle)
Rotates the image in-place to the specified angle.
|
void |
rotateTo(int angle,
DocumentImage dstDocumentImage)
Rotates the image to the specified angle.
|
byte[] |
toBuffer(ImageFormat documentImageFormat,
float compressionLevel)
Exports the image to a buffer.
|
void |
toBufferObject(ImageFormat documentImageFormat,
float compressionLevel,
ImageBuffer buffer)
Copies the image to a buffer in the specified format.
|
void |
toFile(java.lang.String filepath,
float compressionLevel)
Saves the image to the specified file.
|
void |
toRawBuffer(PixelFormat pixelFormat,
ImageBuffer buffer)
Copies image pixels in the specified format into a buffer.
|
void |
transpose()
Transposes the image object.
|
public DocumentImage()
throws DocumentException
DocumentException - An error has occurred during Document Library execution.public DocumentImage(long handle)
throws DocumentException
handle - Handle to the DocumentImage.DocumentException - An error has occurred during Document Library execution.public void close()
close in interface java.lang.AutoCloseableprotected void finalize()
finalize in class java.lang.Objectpublic long getHandle()
public DocumentImage clone() throws DocumentException
clone in class java.lang.ObjectDocumentException - An error has occurred during Document Library execution.public byte[] getData()
throws DocumentException
DocumentException - An error has occurred during Document Library execution.public int getHeight()
throws DocumentException
DocumentException - An error has occurred during Document Library execution.public int getPixelDepth()
throws DocumentException
DocumentException - An error has occurred during Document Library execution.public PixelFormat getPixelFormat() throws DocumentException
DocumentException - An error has occurred during Document Library execution.public int getStride()
throws DocumentException
DocumentException - An error has occurred during Document Library execution.public int getWidth()
throws DocumentException
DocumentException - An error has occurred during Document Library execution.public float compare(DocumentImage cmpDocumentImage) throws DocumentException
cmpDocumentImage - The image to compare.DocumentException - An error has occurred during Document Library execution.public void correctGamma(int contrast,
int brightness,
float gamma)
throws DocumentException
contrast - Contrast coefficient, from -255 to 255, to be applied to the image.brightness - Brightness coefficient, from -255 to 255, to be applid to the image.gamma - Gamma coefficient, from 0.25 to 2.50, to be applied to the image.DocumentException - An error has occurred during Document Library execution.public DocumentImage crop(int left, int top, int width, int height) throws DocumentException
left - Left bound of the crop to extract.top - Top bound of the crop to extract.width - Width of the crop to extract.height - Height of the crop to extract.DocumentException - An error has occurred during Document Library execution.public float downscale(int maxSize)
throws DocumentException
maxSize - Maximum image size, in pixels. The value must be greater than 0.DocumentException - An error has occurred during Document Library execution.public float downscaleTo(DocumentImage dstDocumentImage, int maxSize) throws DocumentException
dstDocumentImage - Destination image.maxSize - Maximum image size, in pixels. The value must be greater than 0.DocumentException - An error has occurred during Document Library execution.public DocumentImage extractRoi(Rectangle bounds) throws DocumentException
bounds - Bounds of the crop to extract.DocumentException - An error has occurred during Document Library execution.public DocumentImage extractRoiWithColor(Rectangle bounds, int colorRed, int colorGreen, int colorBlue) throws DocumentException
bounds - Bounds of the crop to extract.colorRed - Background color red (from 0 to 255)colorGreen - Background color green (from 0 to 255)colorBlue - Background color blue (from 0 to 255)DocumentException - An error has occurred during Document Library execution.public void flip(boolean flipHorizontally,
boolean flipVertically)
throws DocumentException
flipHorizontally - Value indicating whether the image should be flipped horizontally.flipVertically - Value indicating whether the image should be flipped vertically.DocumentException - An error has occurred during Document Library execution.public void flipTo(boolean flipHorizontally,
boolean flipVertically,
DocumentImage dstDocumentImage)
throws DocumentException
flipHorizontally - Value indicating whether the image should be flipped horizontally.flipVertically - Value indicating whether the image should be flipped vertically.dstDocumentImage - The destination Image object that receives the flipped image.DocumentException - An error has occurred during Document Library execution.public static DocumentImage fromBuffer(byte[] data, PixelFormat pixelFormat) throws DocumentException
data - A buffer that contains the image data.pixelFormat - The destination pixel format to convert the input to.DocumentException - An error has occurred during Document Library execution.public static DocumentImage fromFile(java.lang.String filepath, PixelFormat pixelFormat) throws DocumentException
filepath - A string that contains the name of the file from which to create the Image.pixelFormat - The pixel format into which to convert the input image.DocumentException - An error has occurred during Document Library execution.public static DocumentImage fromRawBuffer(byte[] pixels, int width, int height, int stride, PixelFormat srcPixelFormat, PixelFormat dstPixelFormat) throws DocumentException
pixels - A buffer that contains image pixels.width - The width, in pixels, of the image.height - The height, in pixels, of the image.stride - The stride, in pixels, of the image.srcPixelFormat - The pixel format of the input image.dstPixelFormat - The pixel format into which to convert the input image.DocumentException - An error has occurred during Document Library execution.public static DocumentImage fromYuvPlanes(byte[] yPlane, byte[] uPlane, byte[] vPlane, int yWidth, int yHeight, int uvPixelStride, int uvRowStride, PixelFormat dstPixelFormat) throws DocumentException
yPlane - A buffer that contains the Y plane.uPlane - A buffer that contains the U plane.vPlane - A buffer that contains the V plane.yWidth - The width, in pixels, of the Y plane.yHeight - The height, in pixels, of the Y plane.uvPixelStride - The pixel-level stride, in pixels, of the U and V planes.uvRowStride - The row-level stride, in pixels, of the U and V planes.dstPixelFormat - The pixel format into which to convert the input image.DocumentException - An error has occurred during Document Library execution.public void pad(int top,
int left,
int bottom,
int right,
int colorRed,
int colorGreen,
int colorBlue)
throws DocumentException
top - Padding on top.left - Padding on left.bottom - Padding on bottom.right - Padding on right.colorRed - Padding color red (from 0 to 255)colorGreen - Padding color green (from 0 to 255)colorBlue - Padding color blue (from 0 to 255)DocumentException - An error has occurred during Document Library execution.public void reallocate(int width,
int height,
PixelFormat pixelFormat)
throws DocumentException
width - The new width, in pixels.height - The new height, in pixels.pixelFormat - The new pixel format.DocumentException - An error has occurred during Document Library execution.public void resize(int width,
int height)
throws DocumentException
width - The new width, in pixels.height - The new height, in pixels.DocumentException - An error has occurred during Document Library execution.public void resizeTo(int width,
int height,
DocumentImage dstDocumentImage)
throws DocumentException
width - The new width, in pixels.height - The new height, in pixels.dstDocumentImage - The destination image that receives the resized image.DocumentException - An error has occurred during Document Library execution.public void rotate(int angle)
throws DocumentException
angle - The rotation angle, in degree. Supported values are [0, 90, 180, 270].DocumentException - An error has occurred during Document Library execution.public void rotateTo(int angle,
DocumentImage dstDocumentImage)
throws DocumentException
angle - The rotation angle, in degree. Supported values are [0, 90, 180, 270].dstDocumentImage - The destination Image that receives the rotated image.DocumentException - An error has occurred during Document Library execution.public byte[] toBuffer(ImageFormat documentImageFormat, float compressionLevel) throws DocumentException
documentImageFormat - The image format to export the image to.compressionLevel - The compression level to be applied.DocumentException - An error has occurred during Document Library execution.public void toBufferObject(ImageFormat documentImageFormat, float compressionLevel, ImageBuffer buffer) throws DocumentException
documentImageFormat - The output image format.compressionLevel - The compression level to be applied.buffer - The image buffer that receives the image data.DocumentException - An error has occurred during Document Library execution.public void toFile(java.lang.String filepath,
float compressionLevel)
throws DocumentException
filepath - A string that contains the name of the file to which to save the image.compressionLevel - The compression level to be applied.DocumentException - An error has occurred during Document Library execution.public void toRawBuffer(PixelFormat pixelFormat, ImageBuffer buffer) throws DocumentException
pixelFormat - The pixel format.buffer - Buffer that receives the raw image data.DocumentException - An error has occurred during Document Library execution.public void transpose()
throws DocumentException
DocumentException - An error has occurred during Document Library execution.Copyright © 2020-2030, id3 Technologies. All rights reserved. eu.id3.document