Foxit PDF SDK

Public Member Functions | Static Public Attributes | List of all members
FSDK.Image Class Reference

## Public Member Functions
| AddFrame (bitmap)
| Add a bitmap as a frame. (Unsupported DIB formats: FSDK.Bitmap.e_DIBRgb565 and FSDK.Bitmap.e_DIB8bppMask) More...
| constructor ()
| Constructor. More...
| constructor (buffer, length)
| Constructor, from a memory buffer. More...
| constructor (file_read)
| Constructor, with a file read callback object. More...
| constructor (path)
| Constructor, from an existing image file path. More...
| GetFrameBitmap (index)
| Get a frame bitmap, specified by index. More...
| GetFrameCount ()
| Get frame count. More...
| GetHeight ()
| Get image height. More...
| GetOrientation ()
| Get image orientation. More...
| GetType ()
| Get image type. More...
| GetWidth ()
| Get image width. More...
| GetXDPI ()
| Get DPI for X-axis. More...
| GetYDPI ()
| Get DPI for Y-axis. More...
| IsEmpty ()
| Check whether current object is empty or not. More...
| SaveAs (file, file_extension)
| Save current image as an image file. More...
| SaveAs (file_path)
| Save current image as an image file. More...
| SetDPIs (x_dpi, y_dpi)
| Set DPI for X-axis and Y-axis. More...

## Static Public Attributes
static | e_BMP
| Image type is BMP.
static | e_GIF
| Image type is GIF.
static | e_JBIG2
| Image type is JBIG2. More...
static | e_JPG
| Image type is JPG or JPEG.
static | e_JPX
| Image type is JPX or JPEG-2000.
static | e_None
| Not have image type yet. More...
static | e_OrientationFlipH
| Flip Horizontal.
static | e_OrientationFlipV
| Flip Vertical.
static | e_OrientationNone
| Enumeration for image orientation. More...
static | e_OrientationNormal
| Normal orientation.
static | e_OrientationRotate180
| Rotate 180 degrees in clockwise direction.
static | e_OrientationRotate270
| Rotate 90 degrees in counter-clockwise direction.
static | e_OrientationRotate270FlipH
| First rotate 90 in counter-clockwise direction and then flip horizontal.
static | e_OrientationRotate90
| Rotate 90 degrees in clockwise direction.
static | e_OrientationRotate90FlipH
| First rotate 90 in clockwise direction and then flip horizontal.
static | e_PNG
| Image type is PNG.
static | e_TIF
| Image type is TIF or TIFF.
static | e_Unknown
| Enumeration for image type. More...

## 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.

## Member Function Documentation

## ◆ AddFrame()

FSDK.Image.AddFrame | ( | bitmap |  | ) |

Add a bitmap as a frame. (Unsupported DIB formats: FSDK.Bitmap.e_DIBRgb565 and FSDK.Bitmap.e_DIB8bppMask)

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

- If current image's type is FSDK.Image.e_TIF, FSDK.Image.e_GIF, or FSDK.Image.e_None, this function will add the new bitmap to be the new last frame.
- If current image's type is one of other types, which only contains single frame, this function will use the new bitmap to replace the first frame.

Parameters

  [in] | bitmap | A valid bitmap as a frame to be added or set.

Returns
  true means success, while false means failure.

## ◆ constructor() [1/4]

FSDK.Image.constructor | ( |  | ) |

Constructor.

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

## ◆ constructor() [2/4]

FSDK.Image.constructor | ( | buffer | ,
|  | length |
| ) |  |

Constructor, from a memory buffer.

Parameters

  [in] | buffer | A memory buffer. The image file data should be fully loaded in this memory buffer. It should not be null.
  [in] | length | The size of memory buffer. It should be above 0.

## ◆ constructor() [3/4]

FSDK.Image.constructor | ( | file_read |  | ) |

Constructor, with a file read callback object.

Parameters

  [in] | file_read | A FSDK.FileReaderCallback object which is implemented by user to load an image file. It should not be null.

## ◆ constructor() [4/4]

FSDK.Image.constructor | ( | path |  | ) |

Constructor, from an existing image file path.

Parameters

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

## ◆ GetFrameBitmap()

FSDK.Image.GetFrameBitmap | ( | index |  | ) |

Get a frame bitmap, specified by index.

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

Parameters

  [in] | index | Index of the frame. Valid range: from 0 to (count-1). count is returned by function FSDK.Image.GetFrameCount.

Returns
  The frame bitmap. If the return value of function FSDK.Bitmap.IsEmpty for the returned bitmap object is true, that means the frame's DIB format is not supported.

## ◆ GetFrameCount()

FSDK.Image.GetFrameCount | ( |  | ) |

Get frame count.

Currently, this function does not support an image with type FSDK.Image.e_JBIG2.

Returns
  The frame count.

## ◆ GetHeight()

FSDK.Image.GetHeight | ( |  | ) |

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.

## ◆ GetOrientation()

FSDK.Image.GetOrientation | ( |  | ) |

Get image orientation.

This function only support an image with type FSDK.Image.e_JPG and FSDK.Image.e_TIF.

Returns
  Image orientation. Please refer to values starting from FSDK.Image.e_OrientationNone and this would be one of these values.

## ◆ GetType()

FSDK.Image.GetType | ( |  | ) |

Get image type.

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

Returns
  Image type. Please refer to values starting from FSDK.Image.e_Unknown and this would be one of these values.

## ◆ GetWidth()

FSDK.Image.GetWidth | ( |  | ) |

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()

FSDK.Image.GetXDPI | ( |  | ) |

Get DPI for X-axis.

Currently, this function does not support an image with type FSDK.Image.e_JPX, FSDK.Image.e_GIF or FSDK.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()

FSDK.Image.GetYDPI | ( |  | ) |

Get DPI for Y-axis.

Currently, this function does not support an image with type FSDK.Image.e_JPX, FSDK.Image.e_GIF or FSDK.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()

FSDK.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]

FSDK.Image.SaveAs | ( | file | ,
|  | file_extension |
| ) |  |

Save current image as an image file.

If the type of current image is FSDK.Image.e_TIF, FSDK.Image.e_GIF or FSDK.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 | A FSDK.StreamCallback object which is implemented by user to save image file.
  [in] | file_extension | A 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]

FSDK.Image.SaveAs | ( | file_path |  | ) |

Save current image as an image file.

If the type of current image is FSDK.Image.e_TIF, FSDK.Image.e_GIF or FSDK.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_path | A 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()

FSDK.Image.SetDPIs | ( | x_dpi | ,
|  | y_dpi |
| ) |  |

Set DPI for X-axis and Y-axis.

Currently, this function does not support an image with type FSDK.Image.e_JPX, FSDK.Image.e_GIF, or FSDK.Image.e_JBIG2.

Parameters

  [in] | x_dpi | DPI for X-axis. It should be above 0.
  [in] | y_dpi | DPI for Y-axis. It should be above 0.

Returns
  None.

## Member Data Documentation

## ◆ e_JBIG2

FSDK.Image.e_JBIG2
| static

Image type is JBIG2.

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

## ◆ e_None

FSDK.Image.e_None
| 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.

## ◆ e_OrientationNone

FSDK.Image.e_OrientationNone
| static

Enumeration for image orientation.

Values of this enumeration should be used alone.

No orientation.

## ◆ e_Unknown

FSDK.Image.e_Unknown
| static

Enumeration for image type.

Values of this enumeration should be used alone.

Unknown image type.