Foxit PDF SDK
FSImage Class Reference
Inheritance diagram for FSImage:
FSBase

Instance Methods

(BOOL) - addFrame:
 Add a bitmap as a frame. (Unsupported DIB formats: FSBitmapDIBRgb565 and FSBitmapDIB8bppMask)
More...
 
(FSBitmap *) - getFrameBitmap:
 Get a frame bitmap, specified by index.
More...
 
(int) - getFrameCount
 Get frame count.
More...
 
(int) - getHeight
 Get image height.
More...
 
(FSImageType- getType
 Get image type.
More...
 
(int) - getWidth
 Get image width.
More...
 
(int) - getXDPI
 Get DPI for X-axis.
More...
 
(int) - getYDPI
 Get DPI for Y-axis.
More...
 
(id) - init
 Constructor.
More...
 
(id) - initWithBuffer:
 Constructor, from a memory buffer.
More...
 
(id) - initWithFile_read:
 Constructor, with a file read callback object.
More...
 
(id) - initWithOther:
 Constructor, with another image object.
More...
 
(id) - initWithPath:
 Constructor, from an existing image file path.
More...
 
(BOOL) - isEmpty
 Check whether current object is empty or not.
More...
 
(BOOL) - saveAs:
 Save current image as an image file.
More...
 
(BOOL) - saveAsWithStreamCallback:file_extension:
 Save current image as an image file.
More...
 
(void) - setDPIs:y_dpi:
 Set DPI for X-axis and Y-axis.
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.


Method Documentation

◆ addFrame:()

- (BOOL) addFrame: (FSBitmap*)  bitmap

Add a bitmap as a frame. (Unsupported DIB formats: FSBitmapDIBRgb565 and FSBitmapDIB8bppMask)

Currently, this function does not support an image with type FSImageJBIG2, or FSImageUnknown .
For supporting image types:

  • If current image's type is FSImageTIF, FSImageGIF, or FSImageNone, 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]bitmapA valid bitmap as a frame to be added or set.
Returns
YES means success, while NO means failure.

◆ getFrameBitmap:()

- (FSBitmap *) getFrameBitmap: (int)  index

Get a frame bitmap, specified by index.

Currently, this function does not support an image with type FSImageJBIG2. This function can only support to get a frame bitmap which is in following formats:
FSBitmapDIB8bppMask, FSBitmapDIB8bpp, FSBitmapDIBRgb, FSBitmapDIBRgb32, FSBitmapDIBArgb.
For other unsupported DIB format, this function will return a bitmap object which's function FSBitmap::isEmpty returns YES.

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

◆ getFrameCount()

- (int) getFrameCount

Get frame count.

Currently, this function does not support an image with type FSImageJBIG2.

Returns
The frame count.

◆ getHeight()

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

◆ getType()

- (FSImageType) getType

Get image type.

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

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

◆ getWidth()

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

- (int) getXDPI

Get DPI for X-axis.

Currently, this function does not support an image with type FSImageJPX, FSImageGIF or FSImageJBIG2.
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) getYDPI

Get DPI for Y-axis.

Currently, this function does not support an image with type FSImageJPX, FSImageGIF or FSImageJBIG2.
For a new image (not constructed from any image file), the default DPI for Y-axis is 96.

Returns
DPI value for Y-axis.

◆ init()

- (id) init

Constructor.

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

◆ initWithBuffer:()

- (id) initWithBuffer: (NSData *)  buffer

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

◆ initWithFile_read:()

- (id) initWithFile_read: (id<FSFileReaderCallback>)  file_read

Constructor, with a file read callback object.

Parameters
[in]file_readA FSFileReaderCallback object which is implemented by user to load an image file. It should not be nil.

◆ initWithOther:()

- (id) initWithOther: (FSImage*)  other

Constructor, with another image object.

Parameters
[in]otherAnother image object.

◆ initWithPath:()

- (id) initWithPath: (NSString *)  path

Constructor, from an existing image file path.

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

◆ isEmpty()

- (BOOL) isEmpty

Check whether current object is empty or not.

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

Returns
YES means current object is empty, while NO means not.

◆ saveAs:()

- (BOOL) saveAs: (NSString *)  file_path

Save current image as an image file.

If the type of current image is FSImageTIF, FSImageGIF or FSImageNone, 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
YES means success, while NO 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".

◆ saveAsWithStreamCallback:file_extension:()

- (BOOL) saveAsWithStreamCallback: (id<FSFileStreamCallback>)  file
file_extension: (NSString *)  file_extension 

Save current image as an image file.

If the type of current image is FSImageTIF, FSImageGIF or FSImageNone, 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 FSFileStreamCallback 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
YES means success, while NO 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:y_dpi:()

- (void) setDPIs: (int)  x_dpi
y_dpi: (int)  y_dpi 

Set DPI for X-axis and Y-axis.

Currently, this function does not support an image with type FSImageJPX, FSImageGIF, or FSImageJBIG2.

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.