public class Image
extends java.lang.Object
Note: PDF::Element contains a similar interface used to access image data. To create the Image object from image PDF::Element, pass the Element's SDF/Cos dictionary to Image constructor (i.e. Image image(element->GetXObject()) )
Modifier and Type | Field and Description |
---|---|
static int |
e_ascii_hex
The Constant e_ascii_hex.
|
static int |
e_flate
The Constant e_flate.
|
static int |
e_g3
The Constant e_g3.
|
static int |
e_g4
The Constant e_g4.
|
static int |
e_jp2
The Constant e_jp2.
|
static int |
e_jpeg
The Constant e_jpeg.
|
static int |
e_none
The Constant e_none.
|
Constructor and Description |
---|
Image(Obj image_xobject)
Create an image from an existing image represented as a SDF/Cos object.
|
Modifier and Type | Method and Description |
---|---|
static Image |
create(Doc doc,
byte[] image_data)
Create an embed Image from buffer
|
static Image |
create(Doc doc,
byte[] image_data,
int width,
int height,
int bpc,
ColorSpace color_space)
Create an embed Image.
|
static Image |
create(Doc doc,
byte[] image_data,
int width,
int height,
int bpc,
ColorSpace color_space,
int input_format)
Directly embed the image that is already compressed using the Image::InputFilter
format.
|
static Image |
create(Doc doc,
byte[] image_data,
int width,
int height,
int bpc,
ColorSpace color_space,
Obj encoder_hint)
Create an embed Image from buffer
|
static Image |
create(Doc doc,
byte[] image_data,
Obj encoder_hint)
Create an embed Image from buffer
|
static Image |
create(Doc doc,
Filter stream)
Create an embed Image from buffer
|
static Image |
create(Doc doc,
Filter stream,
Obj encoder_hint)
Create an embed Image from buffer
Note: PDFNet takes ownership of the filter stream and it should not be accessed after calling this method. |
static Image |
create(Doc doc,
FilterReader image_data,
int width,
int height,
int bpc,
ColorSpace color_space)
Create and embed an Image.
|
static Image |
create(Doc doc,
FilterReader image_data,
int width,
int height,
int bpc,
ColorSpace color_space,
int input_format)
Embed the raw image data taking into account specified compression hints.
|
static Image |
create(Doc doc,
FilterReader image_data,
int width,
int height,
int bpc,
ColorSpace color_space,
Obj encoder_hint)
Creates an embeded image in document
|
static Image |
create(Doc doc,
java.awt.Image i)
Creates an embeded image from an Image object
|
static Image |
create(Doc doc,
java.lang.String filename)
Create and embed an Image from an external file.
|
static Image |
create(Doc doc,
java.lang.String filename,
Obj encoder_hint)
Create and embed an Image from an external file.
|
static Image |
createImageMask(Doc doc,
byte[] image_data,
int width,
int height)
Create and embed an ImageMask.
|
static Image |
createImageMask(Doc doc,
byte[] image_data,
int width,
int height,
Obj encoder_hint)
Creates the image mask.
|
static Image |
createImageMask(Doc doc,
FilterReader image_data,
int width,
int height)
Create and embed an ImageMask.
|
static Image |
createImageMask(Doc doc,
FilterReader image_data,
int width,
int height,
Obj encoder_hint)
Creates the image mask.
|
static Image |
createSoftMask(Doc doc,
byte[] image_data,
int width,
int height,
int bpc)
Create and embed a Soft Mask.
|
static Image |
createSoftMask(Doc doc,
byte[] image_data,
int width,
int height,
int bpc,
Obj encoder_hint)
Creates the soft mask.
|
static Image |
createSoftMask(Doc doc,
FilterReader image_data,
int width,
int height,
int bpc)
Create and embed a Soft Mask.
|
static Image |
createSoftMask(Doc doc,
FilterReader image_data,
int width,
int height,
int bpc,
Obj encoder_hint)
Creates the soft mask.
|
int |
export(FilterWriter writer)
Saves this image to the output stream.
|
int |
export(java.lang.String filename)
Save this image to a file.
|
void |
exportAsPng(FilterWriter writer)
Saves this image to a PNG output stream.
|
void |
exportAsPng(java.lang.String filename)
Saves this image to a PNG file.
|
void |
exportAsTiff(FilterWriter writer)
Saves this image to a TIFF output stream.
|
void |
exportAsTiff(java.lang.String filename)
Saves this image to a TIFF file.
|
java.awt.Image |
getBitmap()
Get the bitmap of the current image
|
int |
getBitsPerComponent()
Get the bits per component.
|
int |
getComponentNum()
Get the component number
|
Obj |
getDecodeArray()
Get the decode array.
|
ColorSpace |
getImageColorSpace()
Get the image color space.
|
Filter |
getImageData()
Get the image data as filter
|
int |
getImageDataSize()
Get the image data size.
|
int |
getImageHeight()
Get the image height.
|
int |
getImageRenderingIntent()
Get the current image rendering intent.
|
int |
getImageWidth()
Get the image width.
|
Obj |
getMask()
Get the mask from current image
|
Obj |
getSDFObj()
Get the SDFObj.
|
Obj |
getSoftMask()
Get the soft mask from current image
|
boolean |
isImageInterpolate()
Checks if current image is image interpolate.
|
boolean |
isImageMask()
Checks if current image is image mask.
|
boolean |
isValid()
Checks if current image is valid.
|
void |
setMask(Image image_mask)
Set an Explicit Image Mask.
|
void |
setMask(Obj mask)
Set a Color Key Mask.
|
void |
setSoftMask(Image soft_mask)
Set a Soft Mask from current image
|
public static final int e_none
public static final int e_jpeg
public static final int e_jp2
public static final int e_flate
public static final int e_g3
public static final int e_g4
public static final int e_ascii_hex
public Image(Obj image_xobject)
Note: To create the Image object from image PDF::Element, pass the Element's SDF/Cos dictionary to Image constructor (i.e. Image image(element->GetXObject()))
image_xobject
- the image_xobjectpublic static Image create(Doc doc, java.lang.String filename) throws PDFNetException
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().filename
- - The name of the image file. Currently supported formats are
JPEG, PNG, GIF, TIFF, BMP, EMF, and WMF. Other raster formats can be embedded by
decompressing image data and using other versions of Image.Create(...) method.PDFNetException
public static Image create(Doc doc, java.lang.String filename, Obj encoder_hint) throws PDFNetException
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().filename
- The name of the image file. Currently supported formats are
JPEG, PNG, GIF, TIFF, BMP, EMF, and WMFencoder_hint
- a parameter to fine tune compression or to select a different compression algorithmPDFNetException
public static Image create(Doc doc, byte[] image_data, int width, int height, int bpc, ColorSpace color_space) throws PDFNetException
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().image_data
- - The stream or buffer containing image data. The image data must
not be compressed and must follow PDF format for sample representation (please refer
to section 4.8.2 'Sample Representation' in PDF Reference Manual for details).width
- - The width of the image, in samples.height
- - The height of the image, in samples.bpc
- - The number of bits used to represent each color component.color_space
- - The color space in which image samples are represented.PDFNetException
public static Image create(Doc doc, byte[] image_data, int width, int height, int bpc, ColorSpace color_space, Obj encoder_hint) throws PDFNetException
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().image_data
- - The stream or buffer containing image data. The image data must
not be compressed and must follow PDF format for sample representation (please refer
to section 4.8.2 'Sample Representation' in PDF Reference Manual for details).width
- - The width of the image, in samples.height
- - The height of the image, in samples.bpc
- - The number of bits used to represent each color component.color_space
- - The color space in which image samples are represented.encoder_hint
- a parameter to fine tune compression or to select a different compression algorithmPDFNetException
public static Image create(Doc doc, byte[] image_data) throws PDFNetException
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().image_data
- - The stream or buffer containing image data. The image data must
not be compressed and must follow PDF format for sample representation (please refer
to section 4.8.2 'Sample Representation' in PDF Reference Manual for details).PDFNetException
public static Image create(Doc doc, byte[] image_data, Obj encoder_hint) throws PDFNetException
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().image_data
- - The stream or buffer containing image data. The image data must
not be compressed and must follow PDF format for sample representation (please refer
to section 4.8.2 'Sample Representation' in PDF Reference Manual for details).encoder_hint
- a parameter to fine tune compression or to select a different compression algorithmPDFNetException
public static Image create(Doc doc, Filter stream) throws PDFNetException
Note: PDFNet takes ownership of the filter stream and it should not be accessed after calling this method.
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().stream
- - The stream or buffer containing image data. The image data must
not be compressed and must follow PDF format for sample representation (please refer
to section 4.8.2 'Sample Representation' in PDF Reference Manual for details).PDFNetException
public static Image create(Doc doc, Filter stream, Obj encoder_hint) throws PDFNetException
Note: PDFNet takes ownership of the filter stream and it should not be accessed after calling this method.
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().stream
- - The stream or buffer containing image data. The image data must
not be compressed and must follow PDF format for sample representation (please refer
to section 4.8.2 'Sample Representation' in PDF Reference Manual for details).encoder_hint
- a parameter to fine tune compression or to select a different compression algorithmPDFNetException
public static Image create(Doc doc, FilterReader image_data, int width, int height, int bpc, ColorSpace color_space) throws PDFNetException
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().image_data
- - The stream or buffer containing image data. The image data must
not be compressed and must follow PDF format for sample representation (please refer
to section 4.8.2 'Sample Representation' in PDF Reference Manual for details).width
- - The width of the image, in samples.height
- - The height of the image, in samples.bpc
- - The number of bits used to represent each color component.color_space
- - The color space in which image samples are represented.PDFNetException
public static Image create(Doc doc, FilterReader image_data, int width, int height, int bpc, ColorSpace color_space, Obj encoder_hint) throws PDFNetException
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().image_data
- the image_datawidth
- - The width of the image, in samples.height
- - The height of the image, in samples.bpc
- - The number of bits used to represent each color component.color_space
- - The color space in which image samples are represented.encoder_hint
- a parameter to fine tune compression or to select a different compression algorithmPDFNetException
public static Image createImageMask(Doc doc, byte[] image_data, int width, int height) throws PDFNetException
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().image_data
- - The stream or buffer containing image data stored in 1 bit per
sample format. The image data must not be compressed and must follow PDF format for
sample representation (please refer to section 4.8.2 'Sample Representation' in PDF
Reference Manual for details).width
- - The width of the image, in samples.height
- - The height of the image, in samples.PDFNetException
public static Image createImageMask(Doc doc, byte[] image_data, int width, int height, Obj encoder_hint) throws PDFNetException
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().image_data
- the image_datawidth
- - The width of the image, in samples.height
- - The height of the image, in samples.encoder_hint
- a parameter to fine tune compression or to select a different compression algorithmPDFNetException
public static Image createImageMask(Doc doc, FilterReader image_data, int width, int height) throws PDFNetException
Note: see Image::CreateImageMask for details.
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().image_data
- the image_datawidth
- - The width of the image, in samples.height
- - The height of the image, in samples.PDFNetException
public static Image createImageMask(Doc doc, FilterReader image_data, int width, int height, Obj encoder_hint) throws PDFNetException
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().image_data
- the image_datawidth
- - The width of the image, in samples.height
- - The height of the image, in samples.encoder_hint
- a parameter to fine tune compression or to select a different compression algorithmPDFNetException
public static Image createSoftMask(Doc doc, byte[] image_data, int width, int height, int bpc) throws PDFNetException
Note: this feature is available only in PDF 1.4 and higher.
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().image_data
- - The stream or buffer containing image data represented in
DeviceGray color space (i.e. one component per sample). The image data must not
be compressed and must follow PDF format for sample representation (please refer
to section 4.8.2 'Sample Representation' in PDF Reference Manual for details).width
- - The width of the image, in samples.height
- - The height of the image, in samples.bpc
- - The number of bits used to represent each color component.PDFNetException
public static Image createSoftMask(Doc doc, byte[] image_data, int width, int height, int bpc, Obj encoder_hint) throws PDFNetException
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().image_data
- the buffer contain image datawidth
- - The width of the image, in samples.height
- - The height of the image, in samples.bpc
- - The number of bits used to represent each color component.encoder_hint
- a parameter to fine tune compression or to select a different compression algorithmPDFNetException
public static Image createSoftMask(Doc doc, FilterReader image_data, int width, int height, int bpc) throws PDFNetException
Note: see Image.CreateSoftMask for details.
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().image_data
- the image_datawidth
- - The width of the image, in samples.height
- - The height of the image, in samples.bpc
- - The number of bits used to represent each color component.PDFNetException
public static Image createSoftMask(Doc doc, FilterReader image_data, int width, int height, int bpc, Obj encoder_hint) throws PDFNetException
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().image_data
- the image buffer as a Filterwidth
- - The width of the image, in samples.height
- - The height of the image, in samples.bpc
- - The number of bits used to represent each color component.encoder_hint
- a parameter to fine tune compression or to select a different compression algorithmPDFNetException
public static Image create(Doc doc, byte[] image_data, int width, int height, int bpc, ColorSpace color_space, int input_format) throws PDFNetException
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().image_data
- - The stream or buffer containing compressed image data.
The compression format must match the input_format parameter.width
- - The width of the image, in samples.height
- - The height of the image, in samples.bpc
- - The number of bits used to represent each color component.color_space
- - The color space in which image samples are specified.input_format
- - Image::InputFilter describing the format of pre-compressed
image data.PDFNetException
public static Image create(Doc doc, FilterReader image_data, int width, int height, int bpc, ColorSpace color_space, int input_format) throws PDFNetException
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().image_data
- the image_datawidth
- - The width of the image, in samples.height
- - The height of the image, in samples.bpc
- - The number of bits used to represent each color component.color_space
- - The color space in which image samples are specified.input_format
- - Image.InputFilter describing the format of pre-compressed image data.PDFNetException
public static Image create(Doc doc, java.awt.Image i) throws PDFNetException, java.lang.InterruptedException
doc
- - A document to which the image should be added. The 'Doc' object
can be obtained using Obj::GetDoc() or PDFDoc::GetSDFDoc().i
- the image to be addedPDFNetException
java.lang.InterruptedException
- the interrupted exceptionpublic java.awt.Image getBitmap() throws PDFNetException
PDFNetException
public Obj getSDFObj()
public boolean isValid() throws PDFNetException
PDFNetException
public Filter getImageData() throws PDFNetException
PDFNetException
public int getImageDataSize() throws PDFNetException
PDFNetException
public ColorSpace getImageColorSpace() throws PDFNetException
PDFNetException
public int getImageWidth() throws PDFNetException
PDFNetException
public int getImageHeight() throws PDFNetException
PDFNetException
public Obj getDecodeArray() throws PDFNetException
PDFNetException
public int getBitsPerComponent() throws PDFNetException
PDFNetException
public int getComponentNum() throws PDFNetException
PDFNetException
public boolean isImageMask() throws PDFNetException
PDFNetException
public boolean isImageInterpolate() throws PDFNetException
PDFNetException
public Obj getMask() throws PDFNetException
PDFNetException
public void setMask(Image image_mask) throws PDFNetException
Note: image_mask must be a valid image mask (i.e. image_mask.IsImageMask() must return true.
image_mask
- the new maskPDFNetException
public void setMask(Obj mask) throws PDFNetException
Note: the current document takes the ownership of the given SDF object.
mask
- is an Cos/SDF array specifying a range of colors to be masked
out. Samples in the image that fall within this range are not painted, allowing
the existing background to show through. The effect is similar to that of the
video technique known as chroma-key. For details of the array format please
refer to section 4.8.5 'Color Key Masking' in PDF Reference Manual.PDFNetException
public Obj getSoftMask() throws PDFNetException
PDFNetException
public void setSoftMask(Image soft_mask) throws PDFNetException
soft_mask
- is a subsidiary Image object defining a soft-mask image
(See section 7.5.4 'Soft-Mask Images' in PDF Reference Manual) to be used
as a source of mask shape or mask opacity values in the transparent imaging
model. The alpha source parameter in the graphics state determines whether
the mask values are interpreted as shape or opacity.PDFNetException
public int getImageRenderingIntent() throws PDFNetException
PDFNetException
public int export(java.lang.String filename) throws PDFNetException
filename
- string that specifies the path name for
the saved image. The filename should not include the extension
which will be appended to the filename string based on the output
format.PDFNetException
public int export(FilterWriter writer) throws PDFNetException
Note: see the overloaded Image::Export method for more information.
writer
- A pointer to FilterWriter used to write to the
output stream. If the parameter is null, nothing will be written
to the output stream, but the function returns the format identifier.PDFNetException
public void exportAsTiff(java.lang.String filename) throws PDFNetException
filename
- string that specifies the path name for
the saved image. The filename should include the file extensionPDFNetException
public void exportAsTiff(FilterWriter writer) throws PDFNetException
writer
- FilterWriter used to write to the output stream.PDFNetException
public void exportAsPng(java.lang.String filename) throws PDFNetException
filename
- string that specifies the path name for
the saved image. The filename should include the file extensionPDFNetException
public void exportAsPng(FilterWriter writer) throws PDFNetException
writer
- FilterWriter used to write to the output stream.PDFNetException