Package com.itextpdf.io.image
Class ImageData
java.lang.Object
com.itextpdf.io.image.ImageData
- Direct Known Subclasses:
-
Jbig2ImageData,Jpeg2000ImageData,JpegImageData,RawImageData,WebPImageData,WmfImageData
Describes encoded image data and the attributes needed to embed it in a document.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intBits per color component.protected intIs the number of components used to encode colorspace.protected intColor-transform selector used by formats that support it.protected byte[]Encoded image bytes, ornulluntil data is loaded fromurl.protected float[]Decode array applied to image samples, ornullwhen no decode array is specified.Parameters associated with the image decoder, ornull.protected booleanWhetherdatais already deflate-compressed.protected intHorizontal resolution in dots per inch, or0when unspecified.protected intVertical resolution in dots per inch, or0when unspecified.protected StringPDF filter name used to decode the image data, ornull.protected floatImage height in pixels.Additional image attributes, ornull.protected ImageDataMask image associated with this image, ornull.protected intSize of the image data in bytes when known.protected booleanWhether interpolation should be requested when rendering the image.protected booleanWhether the image samples are inverted.protected booleanWhether this image is used as an image mask.protected LongDeprecated.protected ImageTypeDetected or declared format of the source image.protected IccProfileICC color profile associated with the image, ornull.protected floatClockwise rotation to apply to the image, in degrees.protected int[]Component-value pairs defining transparent ranges, ornullwhen no range is specified.protected URLSource URL from which the image bytes can be loaded, ornullwhen bytes were supplied directly.protected floatImage width in pixels.protected floatPixel aspect ratio, or0when unspecified. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether this image can be converted to an image mask.booleanChecks if image can be inlineintgetBpc()Gets the number of bits used for each color component.intGets the number of components used to encode colorspace.intGets the color-transform selector.byte[]getData()Gets the encoded image bytes.float[]Gets the image decode array.Gets image decoder parameters.intgetDpiX()Gets the horizontal image resolution.intgetDpiY()Gets the vertical image resolution.Gets the PDF filter name used for the image data.floatGets the image height.Gets additional image attributes.Gets the mask image associated with this image.Gets the source image format.Gets the associated ICC color profile.floatGets the clockwise rotation applied to the image.int[]Gets the component-value pairs that define transparent ranges.getUrl()Gets the source URL.floatgetWidth()Gets the image width.floatGets the pixel aspect ratio.booleanChecks whether image bytes are already deflate-compressed.booleanChecks whether interpolation should be requested while rendering.booleanChecks whether image samples are inverted.booleanisMask()Checks whether this image is an image mask.booleanIndicates whether this instance represents raw sample data.booleanChecks whether this image is a soft mask.protected voidloadData()Load data from URL.voidmakeMask()Converts this image to an image mask.voidsetBpc(int bpc) Sets the number of bits used for each color component.voidsetColorEncodingComponentsNumber(int colorEncodingComponentsNumber) Sets the number of components used to encode colorspace.voidsetColorTransform(int colorTransform) Sets the color-transform selector.voidsetDecode(float[] decode) Sets the image decode array.voidsetDeflated(boolean deflated) Sets whether image bytes are already deflate-compressed.voidsetDpi(int dpiX, int dpiY) Sets the image resolution.voidSets the PDF filter name used for the image data.voidsetHeight(float height) Sets the image height.voidsetImageAttributes(Map<String, Object> imageAttributes) Sets additional image attributes.voidsetImageMask(ImageData imageMask) Associates a mask image with this image.voidsetInterpolation(boolean interpolation) Sets whether interpolation should be requested while rendering.voidsetInverted(boolean inverted) Sets whether image samples are inverted.voidsetProfile(IccProfile profile) Sets the associated ICC color profile.voidsetRotation(float rotation) Sets the clockwise rotation applied to the image.voidsetTransparency(int[] transparency) Sets component-value pairs that define transparent ranges.voidSets the source URL used to load image bytes.voidsetWidth(float width) Sets the image width.voidsetXYRatio(float XYRatio) Sets the pixel aspect ratio.
-
Field Details
-
url
Source URL from which the image bytes can be loaded, ornullwhen bytes were supplied directly. -
transparency
protected int[] transparencyComponent-value pairs defining transparent ranges, ornullwhen no range is specified. -
originalType
Detected or declared format of the source image. -
width
protected float widthImage width in pixels. -
height
protected float heightImage height in pixels. -
data
protected byte[] dataEncoded image bytes, ornulluntil data is loaded fromurl. -
imageSize
protected int imageSizeSize of the image data in bytes when known. -
bpc
protected int bpcBits per color component. -
colorEncodingComponentsNumber
protected int colorEncodingComponentsNumberIs the number of components used to encode colorspace. -
decode
protected float[] decodeDecode array applied to image samples, ornullwhen no decode array is specified. -
decodeParms
Parameters associated with the image decoder, ornull. -
inverted
protected boolean invertedWhether the image samples are inverted. -
rotation
protected float rotationClockwise rotation to apply to the image, in degrees. -
profile
ICC color profile associated with the image, ornull. -
dpiX
protected int dpiXHorizontal resolution in dots per inch, or0when unspecified. -
dpiY
protected int dpiYVertical resolution in dots per inch, or0when unspecified. -
colorTransform
protected int colorTransformColor-transform selector used by formats that support it. -
deflated
protected boolean deflatedWhetherdatais already deflate-compressed. -
mask
protected boolean maskWhether this image is used as an image mask. -
imageMask
Mask image associated with this image, ornull. -
interpolation
protected boolean interpolationWhether interpolation should be requested when rendering the image. -
XYRatio
protected float XYRatioPixel aspect ratio, or0when unspecified. -
filter
PDF filter name used to decode the image data, ornull. -
imageAttributes
Additional image attributes, ornull. -
mySerialId
Deprecated.
-
-
Constructor Details
-
ImageData
Creates image data whose bytes are available from a URL.- Parameters:
-
url- source URL, notnull -
type- source image format
-
ImageData
Creates image data from encoded bytes.- Parameters:
-
bytes- encoded image bytes; the array is retained -
type- source image format
-
-
Method Details
-
isRawImage
public boolean isRawImage()Indicates whether this instance represents raw sample data.- Returns:
-
truefor raw image data;falseotherwise
-
getUrl
Gets the source URL.- Returns:
-
source URL, or
nullwhen the image was created from bytes
-
setUrl
Sets the source URL used to load image bytes.- Parameters:
-
url- source URL, ornull
-
getTransparency
public int[] getTransparency()Gets the component-value pairs that define transparent ranges.- Returns:
-
retained transparency array, or
null
-
setTransparency
public void setTransparency(int[] transparency) Sets component-value pairs that define transparent ranges.- Parameters:
-
transparency- transparency array to retain, ornull
-
isInverted
public boolean isInverted()Checks whether image samples are inverted.- Returns:
-
trueif samples are inverted
-
setInverted
public void setInverted(boolean inverted) Sets whether image samples are inverted.- Parameters:
-
inverted-trueto invert samples
-
getRotation
public float getRotation()Gets the clockwise rotation applied to the image.- Returns:
- rotation in degrees
-
setRotation
public void setRotation(float rotation) Sets the clockwise rotation applied to the image.- Parameters:
-
rotation- rotation in degrees
-
getProfile
Gets the associated ICC color profile.- Returns:
-
ICC profile, or
null
-
setProfile
Sets the associated ICC color profile.- Parameters:
-
profile- ICC profile to associate, ornull
-
getDpiX
public int getDpiX()Gets the horizontal image resolution.- Returns:
-
dots per inch, or
0when unspecified
-
getDpiY
public int getDpiY()Gets the vertical image resolution.- Returns:
-
dots per inch, or
0when unspecified
-
setDpi
public void setDpi(int dpiX, int dpiY) Sets the image resolution.- Parameters:
-
dpiX- horizontal resolution in dots per inch -
dpiY- vertical resolution in dots per inch
-
getColorTransform
public int getColorTransform()Gets the color-transform selector.- Returns:
- color-transform selector
-
setColorTransform
public void setColorTransform(int colorTransform) Sets the color-transform selector.- Parameters:
-
colorTransform- color-transform selector
-
isDeflated
public boolean isDeflated()Checks whether image bytes are already deflate-compressed.- Returns:
-
truewhen the image bytes are deflated
-
setDeflated
public void setDeflated(boolean deflated) Sets whether image bytes are already deflate-compressed.- Parameters:
-
deflated-truewhen the image bytes are deflated
-
getOriginalType
Gets the source image format.- Returns:
- source image format
-
getColorEncodingComponentsNumber
public int getColorEncodingComponentsNumber()Gets the number of components used to encode colorspace.- Returns:
- the number of components used to encode colorspace
-
setColorEncodingComponentsNumber
public void setColorEncodingComponentsNumber(int colorEncodingComponentsNumber) Sets the number of components used to encode colorspace.- Parameters:
-
colorEncodingComponentsNumber- the number of components used to encode colorspace
-
getData
public byte[] getData()Gets the encoded image bytes.- Returns:
-
retained encoded bytes, or
nulluntil loaded
-
canBeMask
public boolean canBeMask()Checks whether this image can be converted to an image mask.- Returns:
-
trueif the color encoding permits masking
-
isMask
public boolean isMask()Checks whether this image is an image mask.- Returns:
-
trueif this image is a mask
-
getImageMask
Gets the mask image associated with this image.- Returns:
-
mask image, or
null
-
setImageMask
Associates a mask image with this image.- Parameters:
-
imageMask- image that has been made a mask - Throws:
-
IOException- if this image is a mask orimageMaskis not a mask
-
isSoftMask
public boolean isSoftMask()Checks whether this image is a soft mask.- Returns:
-
trueif this image is a soft mask
-
makeMask
public void makeMask()Converts this image to an image mask.- Throws:
-
IOException- if this image cannot be used as a mask
-
getWidth
public float getWidth()Gets the image width.- Returns:
- width in pixels
-
setWidth
public void setWidth(float width) Sets the image width.- Parameters:
-
width- width in pixels
-
getHeight
public float getHeight()Gets the image height.- Returns:
- height in pixels
-
setHeight
public void setHeight(float height) Sets the image height.- Parameters:
-
height- height in pixels
-
getBpc
public int getBpc()Gets the number of bits used for each color component.- Returns:
- bits per component
-
setBpc
public void setBpc(int bpc) Sets the number of bits used for each color component.- Parameters:
-
bpc- bits per component
-
isInterpolation
public boolean isInterpolation()Checks whether interpolation should be requested while rendering.- Returns:
-
trueto request interpolation
-
setInterpolation
public void setInterpolation(boolean interpolation) Sets whether interpolation should be requested while rendering.- Parameters:
-
interpolation-trueto request interpolation
-
getXYRatio
public float getXYRatio()Gets the pixel aspect ratio.- Returns:
-
pixel aspect ratio, or
0when unspecified
-
setXYRatio
public void setXYRatio(float XYRatio) Sets the pixel aspect ratio.- Parameters:
-
XYRatio- pixel aspect ratio
-
getImageAttributes
Gets additional image attributes.- Returns:
-
retained attribute map, or
null
-
setImageAttributes
Sets additional image attributes.- Parameters:
-
imageAttributes- attribute map to retain, ornull
-
getFilter
Gets the PDF filter name used for the image data.- Returns:
-
filter name, or
null
-
setFilter
Sets the PDF filter name used for the image data.- Parameters:
-
filter- PDF filter name, ornull
-
getDecodeParms
Gets image decoder parameters.- Returns:
-
retained decoder-parameter map, or
null
-
getDecode
public float[] getDecode()Gets the image decode array.- Returns:
-
retained decode array, or
null
-
setDecode
public void setDecode(float[] decode) Sets the image decode array.- Parameters:
-
decode- decode array to retain, ornull
-
canImageBeInline
public boolean canImageBeInline()Checks if image can be inline- Returns:
- if the image can be inline
-
loadData
Load data from URL. url must be not null. Note, this method doesn't check if data or url is null.- Throws:
-
IOException- if an I/O error occurs.
-