foxit.common.Image Class Reference
Inheritance diagram for foxit.common.Image:
foxit.common.Base

Public Types

enum  Type {
  Type.e_Unknown = -1, Type.e_None = 0, Type.e_BMP = 1, Type.e_JPG = 2,
  Type.e_PNG = 3, Type.e_GIF = 4, Type.e_TIF = 5, Type.e_JPX = 6,
  Type.e_JBIG2 = 8
}
 Enumeration for image type.
More...
 

Public Member Functions

 Image ()
 Constructor. More...
 
 Image (string path)
 Constructor, from an existing image file path. More...
 
 Image (global::System.IntPtr buffer, uint length)
 Constructor, from a memory buffer. More...
 
 Image (FileReaderCallback file_read)
 Constructor, with a file read callback object. More...
 
 Image (Image arg0)
 Constructor, with another image object.

 
bool AddFrame (System.Drawing.Bitmap bitmap)
 Add a bitmap as a frame. (Unsupported DIB formats: e_DIBRgb565 and e_DIB8bppMask) More...
 
System.Drawing.Bitmap GetFrameBitmap (int index)
 Get a frame bitmap, specified by index. More...
 
int GetFrameCount ()
 Get frame count. More...
 
int GetHeight ()
 Get image height. More...
 
Image.Type 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...
 
bool IsEmpty ()
 Check whether current object is empty or not. More...
 
bool SaveAs (string file_path)
 Save current image as an image file. More...
 
bool SaveAs (StreamCallback file, string file_extension)
 Save current image as an image file. More...
 
void SetDPIs (int x_dpi, int 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.

Member Enumeration Documentation

◆ Type

Enumeration for image type.

Values of this enumeration should be used alone.

Enumerator
e_Unknown 

Unknown image type.

e_None 

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_BMP 

Image type is BMP.

e_JPG 

Image type is JPG or JPeg.

e_PNG 

Image type is PNG.

e_GIF 

Image type is GIF.

e_TIF 

Image type is TIF or TIFF.

e_JPX 

Image type is JPX or JPeg-2000.

e_JBIG2 

Image type is JBIG2.

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

Constructor & Destructor Documentation

◆ Image() [1/4]

foxit.common.Image.Image ( )
inline

Constructor.

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

◆ Image() [2/4]

foxit.common.Image.Image ( string  path)
inline

Constructor, from an existing image file path.

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

◆ Image() [3/4]

foxit.common.Image.Image ( global::System.IntPtr  buffer,
uint  length 
)
inline

Constructor, from a memory buffer.

Parameters
bufferA memory buffer. The image file data should be fully loaded in this memory buffer. It should not be null.
lengthThe size of memory buffer. It should be above 0.

◆ Image() [4/4]

foxit.common.Image.Image ( FileReaderCallback  file_read)
inline

Constructor, with a file read callback object.

Parameters
file_readA ReaderCallback object which is implemented by user to load an image file. It should not be null.

Member Function Documentation

◆ AddFrame()

bool foxit.common.Image.AddFrame ( System.Drawing.Bitmap  bitmap)
inline

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

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


If current image's type is e_TIF, e_GIF, or 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
bitmapA valid bitmap as a frame to be added or set.
Returns
true means success, while false means failure.

◆ GetFrameBitmap()

System.Drawing.Bitmap foxit.common.Image.GetFrameBitmap ( int  index)
inline

Get a frame bitmap, specified by index.

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

Parameters
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 common::Bitmap::IsEmpty for the returned bitmap object is true, that means the frame's DIB format is not supported.

◆ GetFrameCount()

int foxit.common.Image.GetFrameCount ( )
inline

Get frame count.

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

Returns
The frame count.

◆ GetHeight()

int foxit.common.Image.GetHeight ( )
inline

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

Image.Type foxit.common.Image.GetType ( )
inline

Get image type.

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

Returns
Image type. Please refer to e_TypeXXX values and it would be one of these values.

◆ GetWidth()

int foxit.common.Image.GetWidth ( )
inline

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 foxit.common.Image.GetXDPI ( )
inline

Get DPI for X-axis.

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

Get DPI for Y-axis.

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

bool foxit.common.Image.IsEmpty ( )
inline

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]

bool foxit.common.Image.SaveAs ( string  file_path)
inline

Save current image as an image file.

If the type of current image is e_TIF, e_GIF or 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
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".

Use current function to save current image object to an temporary file. Here, this temporary file is named as "temp.tmp".
Ensure that current image object has destructed.
Remove "org.bmp" and rename "temp.tmp" to "org.bmp".

◆ SaveAs() [2/2]

bool foxit.common.Image.SaveAs ( StreamCallback  file,
string  file_extension 
)
inline

Save current image as an image file.

If the type of current image is e_TIF, e_GIF or 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
fileA StreamCallback object which is implemented by user to save image file.
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".

Use current function to save current image object to an temporary file. Here, this temporary file is named as "temp.tmp".
Ensure that current image object has destructed.
Remove "org.bmp" and rename "temp.tmp" to "org.bmp".

◆ SetDPIs()

void foxit.common.Image.SetDPIs ( int  x_dpi,
int  y_dpi 
)
inline

Set DPI for X-axis and Y-axis.

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

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

Foxit Software Corporation Logo
@2018 Foxit Software Incorporated. All rights reserved.