Foxit PDF SDK
com.foxit.sdk.common.Image Class Reference
Inheritance diagram for com.foxit.sdk.common.Image:
com.foxit.sdk.common.Base

Public Member Functions

 Image () throws com.foxit.sdk.PDFException
 Constructor.
More...
 
 Image (String path) throws com.foxit.sdk.PDFException
 Constructor, from an existing image file path.
More...
 
 Image (byte[] buffer) throws com.foxit.sdk.PDFException
 Constructor, from a memory buffer.
More...
 
 Image (FileReaderCallback file_read) throws com.foxit.sdk.PDFException
 Constructor, with a file read callback object.
More...
 
 Image (Image other)
 Constructor, with another image object.
More...
 
boolean addFrame (Bitmap bitmap) throws com.foxit.sdk.PDFException
 Add a bitmap as a frame. (Unsupported DIB formats: com.foxit.sdk.common.Bitmap.e_DIBRgb565 and com.foxit.sdk.common.Bitmap.e_DIB8bppMask )
More...
 
Bitmap getFrameBitmap (int index) throws com.foxit.sdk.PDFException
 Get a frame bitmap, specified by index.
More...
 
int getFrameCount () throws com.foxit.sdk.PDFException
 Get frame count.
More...
 
int getHeight () throws com.foxit.sdk.PDFException
 Get image height.
More...
 
int getType () throws com.foxit.sdk.PDFException
 Get image type.
More...
 
int getWidth () throws com.foxit.sdk.PDFException
 Get image width.
More...
 
int getXDPI () throws com.foxit.sdk.PDFException
 Get DPI for X-axis.
More...
 
int getYDPI () throws com.foxit.sdk.PDFException
 Get DPI for Y-axis.
More...
 
boolean isEmpty ()
 Check whether current object is empty or not.
More...
 
boolean saveAs (String file_path) throws com.foxit.sdk.PDFException
 Save current image as an image file.
More...
 
boolean saveAs (StreamCallback file, String file_extension) throws com.foxit.sdk.PDFException
 Save current image as an image file.
More...
 
void setDPIs (int x_dpi, int y_dpi) throws com.foxit.sdk.PDFException
 Set DPI for X-axis and Y-axis.
More...
 

Static Public Attributes

static final int e_BMP = 1
 Image type is BMP.

 
static final int e_GIF = 4
 Image type is GIF.

 
static final int e_JBIG2 = 8
 Image type is JBIG2.
More...
 
static final int e_JPG = 2
 Image type is JPG or JPEG.

 
static final int e_JPX = 6
 Image type is JPX or JPEG-2000.

 
static final int e_None = 0
 Not have image type yet.
More...
 
static final int e_PNG = 3
 Image type is PNG.

 
static final int e_TIF = 5
 Image type is TIF or TIFF.

 
static final int e_Unknown = -1
 Unknown image type.

 

Detailed Description

Foxit PDF SDK offers following image types:

  • BMP: bitmap image format. It only support single frame. Foxit PDF SDK supports to load image from a BMP image file, get some basic information, get its bitmap, change its bitmap and save it as an image file.
  • JPG: joint photographic experts group image format. It only support single frame. Foxit PDF SDK supports to load image from a JPG image file, get some basic information, get its bitmap, change its bitmap and save it as an image file.
  • PNG: portable network graphics image format. It only support single frame. Foxit PDF SDK supports to load image from a PNG image file, get some basic information, get its bitmap, change its bitmap and save it as an image file.
  • GIF: graphics interchange format. It supports multiple frames. Foxit PDF SDK supports to load image from a GIF image file, get its size, get its bitmap, change its bitmap and save it as an image file.
  • TIF: tagged image file format. It supports multiple frames. Foxit PDF SDK supports to load image from a TIF image file, get some basic information, get its bitmap, change its bitmap and save it as an image file.
  • JPX: JPEG-2000 image format. It only support single frame. Foxit PDF SDK supports to load image from a JPX image file, get its size, get its bitmap, change its bitmap and save it as an image file.
  • JBIG2: JBIG2 image format. It only support single frame. Foxit PDF SDK supports to load image from a JBIG2 image file, get its size, and save it as an image file. Foxit PDF SDK does not support to get its frame bitmap yet.


Constructor & Destructor Documentation

◆ Image() [1/5]

com.foxit.sdk.common.Image.Image ( ) throws com.foxit.sdk.PDFException

Constructor.

This constructor is to construct a new image object (without any data). The image type of this constructed image object would be com.foxit.sdk.common.Image.e_None .

◆ Image() [2/5]

com.foxit.sdk.common.Image.Image ( String  path) throws com.foxit.sdk.PDFException

Constructor, from an existing image file path.

Parameters
[in]pathA full path of an existing image file. It should not be an empty string.

◆ Image() [3/5]

com.foxit.sdk.common.Image.Image ( byte []  buffer) throws com.foxit.sdk.PDFException

Constructor, from a memory buffer.

Parameters
[in]bufferA memory buffer. The image file data should be fully loaded in this memory buffer. It should not be null.

◆ Image() [4/5]

com.foxit.sdk.common.Image.Image ( FileReaderCallback  file_read) throws com.foxit.sdk.PDFException

Constructor, with a file read callback object.

Parameters
[in]file_readA com.foxit.sdk.common.fxcrt.FileReaderCallback object which is implemented by user to load an image file. It should not be null.

◆ Image() [5/5]

com.foxit.sdk.common.Image.Image ( Image  other)

Constructor, with another image object.

Parameters
[in]otherAnother image object.

Member Function Documentation

◆ addFrame()

boolean com.foxit.sdk.common.Image.addFrame ( Bitmap  bitmap) throws com.foxit.sdk.PDFException

Add a bitmap as a frame. (Unsupported DIB formats: com.foxit.sdk.common.Bitmap.e_DIBRgb565 and com.foxit.sdk.common.Bitmap.e_DIB8bppMask )

Currently, this function does not support an image with type com.foxit.sdk.common.Image.e_JBIG2 , or com.foxit.sdk.common.Image.e_Unknown .
For supporting image types:


Parameters
[in]bitmapA valid bitmap as a frame to be added or set.
Returns
true means success, while false means failure.

◆ getFrameBitmap()

Bitmap com.foxit.sdk.common.Image.getFrameBitmap ( int  index) throws com.foxit.sdk.PDFException

Get a frame bitmap, specified by index.

Currently, this function does not support an image with type com.foxit.sdk.common.Image.e_JBIG2 . This function can only support to get a frame bitmap which is in following formats:
com.foxit.sdk.common.Bitmap.e_DIB8bppMask , com.foxit.sdk.common.Bitmap.e_DIB8bpp , com.foxit.sdk.common.Bitmap.e_DIBRgb , com.foxit.sdk.common.Bitmap.e_DIBRgb32 , com.foxit.sdk.common.Bitmap.e_DIBArgb .
For other unsupported DIB format, this function will return a bitmap object which's function Bitmap.isEmpty returns true.

Parameters
[in]indexIndex of the frame. Valid range: from 0 to (count-1). count is returned by function Image.getFrameCount .
Returns
The frame bitmap. If the return value of function Bitmap.isEmpty for the returned bitmap object is true, that means the frame's DIB format is not supported.

◆ getFrameCount()

int com.foxit.sdk.common.Image.getFrameCount ( ) throws com.foxit.sdk.PDFException

Get frame count.

Currently, this function does not support an image with type com.foxit.sdk.common.Image.e_JBIG2 .

Returns
The frame count.

◆ getHeight()

int com.foxit.sdk.common.Image.getHeight ( ) throws com.foxit.sdk.PDFException

Get image height.

If the image has multiple frames, usually the first frame's size will be treated as the image size.

Returns
Image height.

◆ getType()

int com.foxit.sdk.common.Image.getType ( ) throws com.foxit.sdk.PDFException

Get image type.

If current image is a new image (not constructed from any image file), its type would be com.foxit.sdk.common.Image.e_None .

Returns
Image type. Please refer to values starting from com.foxit.sdk.common.Image.e_Unknown and this would be one of these values.

◆ getWidth()

int com.foxit.sdk.common.Image.getWidth ( ) throws com.foxit.sdk.PDFException

Get image width.

If the image has multiple frames, usually the first frame's size will be treated as the image size.

Returns
Image width..

◆ getXDPI()

int com.foxit.sdk.common.Image.getXDPI ( ) throws com.foxit.sdk.PDFException

Get DPI for X-axis.

Currently, this function does not support an image with type com.foxit.sdk.common.Image.e_JPX , com.foxit.sdk.common.Image.e_GIF or com.foxit.sdk.common.Image.e_JBIG2 .
For a new image (not constructed from any image file), the default DPI for X-axis is 96.

Returns
DPI value for X-axis.

◆ getYDPI()

int com.foxit.sdk.common.Image.getYDPI ( ) throws com.foxit.sdk.PDFException

Get DPI for Y-axis.

Currently, this function does not support an image with type com.foxit.sdk.common.Image.e_JPX , com.foxit.sdk.common.Image.e_GIF or com.foxit.sdk.common.Image.e_JBIG2 .
For a new image (not constructed from any image file), the default DPI for Y-axis is 96.

Returns
DPI value for Y-axis.

◆ isEmpty()

boolean com.foxit.sdk.common.Image.isEmpty ( )

Check whether current object is empty or not.

When the current object is empty, that means current object is useless.

Returns
true means current object is empty, while false means not.

◆ saveAs() [1/2]

boolean com.foxit.sdk.common.Image.saveAs ( String  file_path) throws com.foxit.sdk.PDFException

Save current image as an image file.

If the type of current image is com.foxit.sdk.common.Image.e_TIF , com.foxit.sdk.common.Image.e_GIF or com.foxit.sdk.common.Image.e_None , and the saved image file type does not support multiply frames, only the first frame of current image will be saved to the image file.
For an image object (not constructed from any image file), please ensure to add at least one valid frame bitmap to the image object before using this function; otherwise this function will fail.

Parameters
[in]file_pathA full path of the saved image file. It should not be an empty string.
Currently, this function supports following extension names:
.bmp, .jpg, .jpeg, .png, .tif, .tiff, .jpx, .jp2.
Returns
true means success, while false means failure.
Note
This function does not support to save current image object just back to the image file which is used to construct current image object. In order to do so, user is recommended to do as following steps:
Assume that current image object is constructed from an image file named "org.bmp".
  1. Use current function to save current image object to an temporary file. Here, this temporary file is named as "temp.tmp".
  2. Ensure that current image object has destructed.
  3. Remove "org.bmp" and rename "temp.tmp" to "org.bmp".

◆ saveAs() [2/2]

boolean com.foxit.sdk.common.Image.saveAs ( StreamCallback  file,
String  file_extension 
) throws com.foxit.sdk.PDFException

Save current image as an image file.

If the type of current image is com.foxit.sdk.common.Image.e_TIF , com.foxit.sdk.common.Image.e_GIF or com.foxit.sdk.common.Image.e_None , and the saved image file type does not support multiply frames, only the first frame of current image will be saved to the image file.
For an image object (not constructed from any image file), please ensure to add at least one valid frame bitmap to the image object before using this function; otherwise this function will fail.

Parameters
[in]fileA com.foxit.sdk.common.fxcrt.StreamCallback object which is implemented by user to save image file.
[in]file_extensionA full path of the saved image file. It should not be an empty string.
Currently, this function supports following extension names:
.bmp, .jpg, .jpeg, .png, .tif, .tiff, .jpx, .jp2.
Returns
true means success, while false means failure.
Note
This function does not support to save current image object just back to the image file which is used to construct current image object. In order to do so, user is recommended to do as following steps:
Assume that current image object is constructed from an image file named "org.bmp".
  1. Use current function to save current image object to an temporary file. Here, this temporary file is named as "temp.tmp".
  2. Ensure that current image object has destructed.
  3. Remove "org.bmp" and rename "temp.tmp" to "org.bmp".

◆ setDPIs()

void com.foxit.sdk.common.Image.setDPIs ( int  x_dpi,
int  y_dpi 
) throws com.foxit.sdk.PDFException

Set DPI for X-axis and Y-axis.

Currently, this function does not support an image with type com.foxit.sdk.common.Image.e_JPX , com.foxit.sdk.common.Image.e_GIF , or com.foxit.sdk.common.Image.e_JBIG2 .

Parameters
[in]x_dpiDPI for X-axis. It should be above 0.
[in]y_dpiDPI for Y-axis. It should be above 0.
Returns
None.

Member Data Documentation

◆ e_JBIG2

final int com.foxit.sdk.common.Image.e_JBIG2 = 8
static

Image type is JBIG2.

Note
Currently, only few functions in class Image support this type.

◆ e_None

final int com.foxit.sdk.common.Image.e_None = 0
static

Not have image type yet.

Note
This is only for a new image object, which is not constructed from any image file or retrieved from other object.