Package com.itextpdf.io.image
Class ImageDataFactory
java.lang.Object
com.itextpdf.io.image.ImageDataFactory
-
Method Summary
Modifier and TypeMethodDescriptionstatic ImageDatacreate(byte[] bytes) Create an ImageData instance representing the image from the image bytes.static ImageDatacreate(byte[] bytes, boolean recoverImage) Create an ImageData instance representing the image from the image bytes.static ImageDatacreate(int width, int height, boolean reverseBits, int typeCCITT, int parameters, byte[] data, int[] transparency) Create an ImageData instance from the passed parameters.static ImageDatacreate(int width, int height, int components, int bpc, byte[] data, int[] transparency) Create an ImageData instance from the passed parameters.static ImageDataGets an instance of an Image from a java.awt.Image.static ImageDataGets an instance of an Image from a java.awt.Image.static ImageDataCreate an ImageData instance representing the image from the specified file.static ImageDataCreate an ImageData instance representing the image from the specified file.static ImageDataCreate an ImageData instance representing the image from the file located at the specified url.static ImageDataCreate an ImageData instance representing the image from the file located at the specified url.static ImageDatacreateBmp(byte[] bytes, boolean noHeader) Gets a bitmap ImageData instance from the provided bytes.static ImageDataGets a bitmap ImageData instance from the specified URL.static GifImageDatacreateGif(byte[] bytes) Return a GifImage object.static ImageDatacreateGifFrame(byte[] bytes, int frame) Returns a specified frame of the gif image.static ImageDatacreateGifFrame(URL url, int frame) Returns a specified frame of the gif image.createGifFrames(byte[] bytes) ReturnsListof gif image frames.createGifFrames(byte[] bytes, int[] frameNumbers) ReturnsListof gif image frames.createGifFrames(URL url) ReturnsListof gif image frames.createGifFrames(URL url, int[] frameNumbers) ReturnsListof gif image frames.static ImageDatacreateJbig2(byte[] bytes, int page) static ImageDatacreateJbig2(URL url, int page) static ImageDatacreateJpeg(byte[] bytes) Creates anImageDatainstance from a JPEG image raw bytes.static ImageDatacreateJpeg(URL url) Create anImageDatainstance from a JPEG image URL.static ImageDatacreateJpeg2000(byte[] bytes) Creates anImageDatainstance from a JPEG2000 image raw bytes.static ImageDatacreateJpeg2000(URL url) Creates anImageDatainstance from a JPEG2000 image URL.static ImageDatacreatePng(byte[] bytes) Creates anImageDatainstance from a PNG image raw bytes.static ImageDataCreates anImageDatainstance from a PNG image URL.static ImageDatacreateRawImage(byte[] bytes) static ImageDatacreateTiff(byte[] bytes, boolean recoverFromImageError, int page, boolean direct) static ImageDatacreateTiff(URL url, boolean recoverFromImageError, int page, boolean direct) static ImageDatacreateWebP(byte[] bytes) Creates anImageDatainstance from a WebP image raw bytes.static ImageDatacreateWebP(URL url) Creates anImageDatainstance from a WebP image URL.static booleanisSupportedType(byte[] source) Checks if the type of image (based on first 8 bytes) is supported by factory.static booleanisSupportedType(ImageType imageType) Checks if the type of image is supported by factory.static booleanisSupportedType(URL source) Checks if the type of image (based on first 8 bytes) is supported by factory.static voidsetWebPLoaderInstance(AbstractWebPLoader newInstance) SetsAbstractWebPLoaderinstance to use.
-
Method Details
-
setWebPLoaderInstance
SetsAbstractWebPLoaderinstance to use.- Parameters:
-
newInstance- the instance to set
-
create
Create an ImageData instance representing the image from the image bytes.- Parameters:
-
bytes- byte representation of the image. -
recoverImage- whether to recover from a image error (for TIFF-images) - Returns:
- The created ImageData object.
-
create
Create an ImageData instance representing the image from the image bytes.- Parameters:
-
bytes- byte representation of the image. - Returns:
- The created ImageData object.
-
create
Create an ImageData instance representing the image from the file located at the specified url.- Parameters:
-
url- location of the image -
recoverImage- whether to recover from a image error (for TIFF-images) - Returns:
- The created ImageData object.
-
create
Create an ImageData instance representing the image from the file located at the specified url.- Parameters:
-
url- location of the image - Returns:
- The created ImageData object.
-
create
Create an ImageData instance representing the image from the specified file.- Parameters:
-
filename- filename of the file containing the image -
recoverImage- whether to recover from a image error (for TIFF-images) - Returns:
- The created ImageData object.
- Throws:
-
MalformedURLException- if an error occurred generating the URL.
-
create
Create an ImageData instance representing the image from the specified file.- Parameters:
-
filename- filename of the file containing the image - Returns:
- The created ImageData object.
- Throws:
-
MalformedURLException- if an error occurred generating the URL.
-
create
public static ImageData create(int width, int height, boolean reverseBits, int typeCCITT, int parameters, byte[] data, int[] transparency) Create an ImageData instance from the passed parameters.- Parameters:
-
width- width of the image in pixels -
height- height of the image in pixels -
reverseBits- whether to reverse the bits stored in data (TIFF images). -
typeCCITT- Type of CCITT encoding -
parameters- colour space parameters -
data- array containing raw image data -
transparency- array containing transparency information - Returns:
- created ImageData object.
-
create
public static ImageData create(int width, int height, int components, int bpc, byte[] data, int[] transparency) Create an ImageData instance from the passed parameters.- Parameters:
-
width- width of the image in pixels -
height- height of the image in pixels -
components- colour space components -
bpc- bits per colour. -
data- array containing raw image data -
transparency- array containing transparency information - Returns:
- created ImageData object.
-
create
Gets an instance of an Image from a java.awt.Image.- Parameters:
-
image- the java.awt.Image to convert -
color- if different fromnullthe transparency pixels are replaced by this color - Returns:
- RawImage
- Throws:
-
IOException- if an I/O error occurs.
-
create
Gets an instance of an Image from a java.awt.Image.- Parameters:
-
image- thejava.awt.Imageto convert -
color- if different fromnullthe transparency pixels are replaced by this color -
forceBW- iftruethe image is treated as black and white - Returns:
- RawImage
- Throws:
-
IOException- if an I/O error occurs.
-
createBmp
Gets a bitmap ImageData instance from the specified URL.- Parameters:
-
url- location of the image -
noHeader- whether the image contains a header - Returns:
- created ImageData
-
createBmp
Gets a bitmap ImageData instance from the provided bytes.- Parameters:
-
bytes- array containing the raw image data -
noHeader- Whether the image contains a header. - Returns:
- created ImageData
-
createGif
Return a GifImage object. This object cannot be added to a document- Parameters:
-
bytes- array containing the raw image data - Returns:
- GifImageData instance.
-
createGifFrame
Returns a specified frame of the gif image.- Parameters:
-
url- url of gif image -
frame- number of frame to be returned, 1-based - Returns:
- GifImageData instance.
-
createGifFrame
Returns a specified frame of the gif image.- Parameters:
-
bytes- byte array of gif image -
frame- number of frame to be returned, 1-based - Returns:
- GifImageData instance
-
createGifFrames
ReturnsListof gif image frames.- Parameters:
-
bytes- byte array of gif image -
frameNumbers- array of frame numbers of gif image, 1-based - Returns:
- all frames of gif image
-
createGifFrames
ReturnsListof gif image frames.- Parameters:
-
url- url of gif image -
frameNumbers- array of frame numbers of gif image, 1-based - Returns:
- all frames of gif image
-
createGifFrames
ReturnsListof gif image frames.- Parameters:
-
bytes- byte array of gif image - Returns:
- all frames of gif image
-
createGifFrames
ReturnsListof gif image frames.- Parameters:
-
url- url of gif image - Returns:
- all frames of gif image
-
createJbig2
-
createJbig2
-
createJpeg
Create anImageDatainstance from a JPEG image URL.- Parameters:
-
url- URL to create JPEG image data from - Returns:
- the created JPEG image
-
createJpeg
Creates anImageDatainstance from a JPEG image raw bytes.- Parameters:
-
bytes- raw bytes to create JPEG image data from - Returns:
- the created JPEG image
-
createJpeg2000
Creates anImageDatainstance from a JPEG2000 image URL.- Parameters:
-
url- URL to create JPEG2000 image data from - Returns:
- the created JPEG2000 image
-
createJpeg2000
Creates anImageDatainstance from a JPEG2000 image raw bytes.- Parameters:
-
bytes- raw bytes to create JPEG2000 image data from - Returns:
- the created JPEG2000 image
-
createPng
Creates anImageDatainstance from a PNG image URL.- Parameters:
-
url- URL to create PNG image data from - Returns:
- the created PNG image
-
createPng
Creates anImageDatainstance from a PNG image raw bytes.- Parameters:
-
bytes- raw bytes to create PNG image data from - Returns:
- the created PNG image
-
createTiff
-
createTiff
public static ImageData createTiff(byte[] bytes, boolean recoverFromImageError, int page, boolean direct) -
createRawImage
-
createWebP
Creates anImageDatainstance from a WebP image URL.- Parameters:
-
url- URL to create WebP image data from - Returns:
- the created WebP image
-
createWebP
Creates anImageDatainstance from a WebP image raw bytes.- Parameters:
-
bytes- raw bytes to create WebP image data from - Returns:
- the created WebP image
-
isSupportedType
public static boolean isSupportedType(byte[] source) Checks if the type of image (based on first 8 bytes) is supported by factory.
Note: if this method returnstrueit doesn't means thatcreate(byte[])won't throw exception- Parameters:
-
source- image raw bytes - Returns:
-
trueif first eight bytes are recognised by factory as valid image type andfalseotherwise
-
isSupportedType
Checks if the type of image (based on first 8 bytes) is supported by factory.
Note: if this method returnstrueit doesn't means thatcreate(byte[])won't throw exception- Parameters:
-
source- image URL - Returns:
-
trueif first eight bytes are recognised by factory as valid image type andfalseotherwise
-
isSupportedType
Checks if the type of image is supported by factory.
Note: if this method returnstrueit doesn't means thatcreate(byte[])won't throw exception- Parameters:
-
imageType- image type - Returns:
-
trueif image type is supported andfalseotherwise
-