Foxit PDF SDK

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

## Public Member Functions
| CalculateBBoxByColor (backgroud_color)
| Calculate the bounding box according to the given background color. More...
| Clone (clip_rect)
| Clone current bitmap, with specified clip rectangle. More...
| constructor (width, height, format, buffer, pitch)
| Constructor, with parameters. More...
| constructor ()
| Constructor, as an empty bitmap object.
| ConvertFormat (format, icc_transform)
| Convert a bitmap to another specified DIB format. More...
| ConvertToMono ()
| Converts bitmap to 1-bit monochrome format. More...
| DetectBBoxByColorDiffer (detection_size, color_differ)
| Detect the bounding box of content according to the given color difference between content and margin. More...
| FillRect (color, rect)
| Fill current bitmap with a specified color. More...
| Flip (is_flip_horz, is_flip_vert)
| Flip bitmap. More...
| GetBpp ()
| Get bitmap bits-per-pixel. More...
| GetBuffer ()
| Get bitmap buffer. More...
| GetFormat ()
| Get bitmap format. More...
| GetHeight ()
| Get bitmap height. More...
| GetMask (clip_rect)
| Get the mask if bitmap has mask. More...
| GetPitch ()
| Get bitmap pitch. More...
| GetWidth ()
| Get bitmap width. More...
| IsEmpty ()
| Check whether current object is empty or not. More...
| StretchTo (dest_width, dest_height, flag, clip_rect)
| Stretch with different size. More...
| SwapXY (is_flip_horz, is_flip_vert, clip_rect)
| Swap X,Y coordinations of the bitmap. After being swapped, the image can also be flipped at the same time. More...
| TransformTo (matrix, flag, out_left, out_top, clip_rect)
| Transform current bitmap (as source bitmap) into destination one. More...

## Static Public Attributes
static | e_Bicubic
| If set, do bicubic interpolation for stretching or transforming.
static | e_DIB1bpp
| DIB format: 1bpp format, two color RGB bitmap.It does not support format conversion and rendering.
static | e_DIB8bpp
| DIB format: 8bpp format, 256 color RGB bitmap.
static | e_DIB8bppGray
| DIB format: 8bpp format, 256 color GrayScale bitmap.
static | e_DIB8bppMask
| DIB format: 8bpp alpha mask.
static | e_DIBAbgr
| DIB format: 32bpp format, with bits order "Red, Green, Blue, Alpha". Red is in the lowest order.
static | e_DIBArgb
| DIB format: 32bpp format, with bits order "Blue, Green, Red, Alpha". Blue is in the lowest order.
static | e_DIBCmyk
| DIB format: 32bpp CMYK format, with bits order "Cyan, Magenta, Yellow, Black". Cyan is in the lowest order.
static | e_DIBInvalid
| Enumeration for DIB format. More...
static | e_DIBRgb
| DIB format: 24bpp format, with bits order "Blue, Green, Red". Blue is in the lowest order.
static | e_DIBRgb32
| DIB format: 32bpp format, with bits order "Blue, Green, Red, not used". Blue is in the lowest order.
static | e_DIBRgb565
| 16bpp format, bits order: Red 5 bits, Green 6 bits, Blue 5 bits. Red is the lowest order.
static | e_Downsample
| Enumeration for bitmap interpolation flags. More...
static | e_Quadratic
| If set, do interpolation for stretching or transforming.

## Detailed Description

Bitmap is one of most important data structures in Foxit PDF SDK. It is commonly used for rendering. This class can construct a new bitmap object (not retrieved from other object) and offer methods to get information or operate the bitmap.

## Member Function Documentation

## ◆ CalculateBBoxByColor()

FSDK.Bitmap.CalculateBBoxByColor | ( | backgroud_color |  | ) |

Calculate the bounding box according to the given background color.

This function can support the following formats:
FSDK.Bitmap.e_DIB8bppMask, FSDK.Bitmap.e_DIB8bpp, FSDK.Bitmap.e_DIBRgb, FSDK.Bitmap.e_DIBRgb32, FSDK.Bitmap.e_DIBArgb.

Parameters

  [in] | backgroud_color | A valid background color. Format: 0xAARRGGBB.

Returns
  The rectangle of bounding box for content.

## ◆ Clone()

FSDK.Bitmap.Clone | ( | clip_rect |  | ) |

Clone current bitmap, with specified clip rectangle.

Parameters

  [in] | clip_rect | The clipping region in current bitmap to specify the region to be cloned. For bitmap format FSDK.Bitmap.e_DIBRgb565, currently only support to clone the whole bitmap, so this should always be null. For rest format, this can be either null or valid. If this is null, that means to clone the whole bitmap. If this is not null, it specifies a clipping region in bitmap to be cloned and the cloned bitmap will have the same size as the clipping region. Default value: null.

Returns
  A new bitmap as cloned result.

## ◆ constructor()

FSDK.Bitmap.constructor | ( | width | ,
|  | height | ,
|  | format | ,
|  | buffer | ,
|  | pitch |
| ) |  |

Constructor, with parameters.

If parameter buffer is not null, it should be initialized by application; if parameter buffer is null, Foxit PDF SDK will allocate and initialize the pixels buffer internally.
Application is suggested to use the same colors as Foxit PDF SDK uses internally to initialize bitmap's pixel buffer:

- For the bitmap without alpha channel, initialize the pixels buffer with 0xFFFFFFFF.
- For the bitmap with alpha channel, initialize the pixels buffer with 0x00000000.

Additionally, there is a size limit for loading images. The image size should meet the condition: width * height * (bits per pixel / 8) < 0x40000000 (indicating 1 GB). Image size refers to the actual data size of the image and not the size of the image file.

Parameters

  [in] | width | Width of bitmap, in pixels. This should be above 0.
  [in] | height | Height of bitmap, in pixels. This should be above 0.
  [in] | format | Bitmap format type. Please refer to values starting from FSDK.Bitmap.e_DIBRgb and this should be one of these values except FSDK.Bitmap.e_DIBInvalid.
  [in] | buffer | A buffer that specifies bitmap data. If it is not null, this function will use the parameter buffer to initialize a bitmap. In this case, please do not free the parameter buffer before the life-cycle of parameter bitmap ends. If it is null, a new bitmap buffer will be created internally. Default value: null.
  [in] | pitch | The number of bytes for each scan line. This is useful only when parameter buffer is not null. If this value is 0, 4-byte alignment is assumed. Default value: 0.

## ◆ ConvertFormat()

FSDK.Bitmap.ConvertFormat | ( | format | ,
|  | icc_transform |
| ) |  |

Convert a bitmap to another specified DIB format.

Parameters

  [in] | format | New bitmap format type. It should be one of following values: FSDK.Bitmap.e_DIB8bppMask, FSDK.Bitmap.e_DIB8bpp, FSDK.Bitmap.e_DIBRgb, FSDK.Bitmap.e_DIBRgb32, FSDK.Bitmap.e_DIBArgb. FSDK.Bitmap.e_DIBRgb565.
  [in] | icc_transform | The color mapping context for source format to destination format. It can be null, which means not use the color mapping. Default value: null.

Returns
  The converted bitmap.

## ◆ ConvertToMono()

FSDK.Bitmap.ConvertToMono | ( |  | ) |

Converts bitmap to 1-bit monochrome format.

The resulting monochrome bitmap uses 1-bit pixel depth format.

Returns
  A new bitmap as a monochrome result.

Note
  The 1-bit monochrome format cannot be preserved when saving as jepg.

## ◆ DetectBBoxByColorDiffer()

FSDK.Bitmap.DetectBBoxByColorDiffer | ( | detection_size | ,
|  | color_differ |
| ) |  |

Detect the bounding box of content according to the given color difference between content and margin.

This function can support the following formats:
FSDK.Bitmap.e_DIB8bppMask, FSDK.Bitmap.e_DIB8bpp, FSDK.Bitmap.e_DIBRgb, FSDK.Bitmap.e_DIBRgb32, FSDK.Bitmap.e_DIBArgb.

Parameters

  [in] | detection_size | Detection size to analyze background.
  [in] | color_differ | Color difference used to detect margin. The value should be between 0 and 255, and the suggested value is 64. Default value: 64.

Returns
  The rectangle of bounding box for content.

## ◆ FillRect()

FSDK.Bitmap.FillRect | ( | color | ,
|  | rect |
| ) |  |

Fill current bitmap with a specified color.

For bitmaps with Bitmap.e_DIBCmyk format, users can fill CMYK color values and the parameter rect must be NULL.

Parameters

  [in] | color | A color value which is used to fill bitmap. Format: 0xAARRGGBB
  [in] | rect | A rectangle that represents a region in bitmap to specify where the color will be filled. This can be null, which means to fill the whole bitmap. Default value: null.

Returns
  None.

## ◆ Flip()

FSDK.Bitmap.Flip | ( | is_flip_horz | ,
|  | is_flip_vert |
| ) |  |

Flip bitmap.

This function can support following formats:
FSDK.Bitmap.e_DIB8bppMask, FSDK.Bitmap.e_DIB8bpp, FSDK.Bitmap.e_DIBRgb, FSDK.Bitmap.e_DIBRgb32, FSDK.Bitmap.e_DIBArgb.

Parameters

  [in] | is_flip_horz | A boolean value to indicate whether to flip bitmap in horizontal direction: true means a bitmap will be flipped in horizontal direction, and false means not.
  [in] | is_flip_vert | A boolean value to indicate whether to flip bitmap in vertical direction. true means a bitmap will be flipped in vertical direction, and false means not.

Returns
  A new bitmap as flipped result.

## ◆ GetBpp()

FSDK.Bitmap.GetBpp | ( |  | ) |

Get bitmap bits-per-pixel.

Returns
  Bitmap bits-per-pixel value.

## ◆ GetBuffer()

FSDK.Bitmap.GetBuffer | ( |  | ) |

Get bitmap buffer.

Bitmap data are organized in scan-lines, from top to down.

Returns
  Bitmap buffer.

## ◆ GetFormat()

FSDK.Bitmap.GetFormat | ( |  | ) |

Get bitmap format.

Returns
  Format value. Please refer to values starting from FSDK.Bitmap.e_DIBInvalid and this would be one of these values.

## ◆ GetHeight()

FSDK.Bitmap.GetHeight | ( |  | ) |

Get bitmap height.

Returns
  Bitmap height.

## ◆ GetMask()

FSDK.Bitmap.GetMask | ( | clip_rect |  | ) |

Get the mask if bitmap has mask.

Parameters

  [in] | clip_rect | The clipping region of current bitmap (as source bitmap). It can be null. Default value: null.

Returns
  A new bitmap as mask bitmap. If the return value of function FSDK.Bitmap.IsEmpty for the returned bitmap object is true, that means current bitmap does not have mask.

## ◆ GetPitch()

FSDK.Bitmap.GetPitch | ( |  | ) |

Get bitmap pitch.

Returns
  Bitmap pitch.

## ◆ GetWidth()

FSDK.Bitmap.GetWidth | ( |  | ) |

Get bitmap width.

Returns
  Bitmap width.

## ◆ IsEmpty()

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

## ◆ StretchTo()

FSDK.Bitmap.StretchTo | ( | dest_width | ,
|  | dest_height | ,
|  | flag | ,
|  | clip_rect |
| ) |  |

Stretch with different size.

If parameter dest_width or parameter dest_height is negative, the bitmap will be flipped. If the stretching is to be done in down-sample mode, that would be much faster than not to be done in down-sample mode, especially when stretching big bitmaps into small ones. Optionally a clipping region in result bitmap coordinate can be specified to limit the size of result bitmap. This function can not support the following format:
FSDK.Bitmap.e_DIBCmyk.

Parameters

  [in] | dest_width | The width of the destination bitmap.
  [in] | dest_height | The height of the destination bitmap.
  [in] | flag | Stretch flag, It should be value FSDK.Bitmap.e_Downsample or FSDK.Bitmap.e_Quadratic.
  [in] | clip_rect | The clipping region of destination bitmap. It can be null. Default value: null.

Returns
  A new bitmap as stretched result.

## ◆ SwapXY()

FSDK.Bitmap.SwapXY | ( | is_flip_horz | ,
|  | is_flip_vert | ,
|  | clip_rect |
| ) |  |

Swap X,Y coordinations of the bitmap. After being swapped, the image can also be flipped at the same time.

This function can support following formats:
FSDK.Bitmap.e_DIB8bppMask, FSDK.Bitmap.e_DIB8bpp, FSDK.Bitmap.e_DIBRgb, FSDK.Bitmap.e_DIBRgb32, FSDK.Bitmap.e_DIBArgb. Optionally a clipping region (in destination bitmap coordinate) can be specified to limit the size of result.
Suppose the original image has the following 4 pixels:

             +---+---+
             | 1 | 2 |
             +---+---+
             | 3 | 4 |
             +---+---+

Then, depends on parameter is_flip_horz and is_flip_vert, the result would look like: if parameter is_flip_horz = false, parameter is_flip_vert = false:

             +---+---+
             | 1 | 3 |
             +---+---+
             | 2 | 4 |
             +---+---+

if parameter is_flip_horz = true, parameter is_flip_vert = false:

             +---+---+
             | 3 | 1 |
             +---+---+
             | 4 | 2 |
             +---+---+

if parameter is_flip_horz = false, parameter is_flip_vert = true:

             +---+---+
             | 2 | 4 |
             +---+---+
             | 1 | 3 |
             +---+---+

if parameter is_flip_horz = true, parameter is_flip_vert = true:

             +---+---+
             | 4 | 2 |
             +---+---+
             | 3 | 1 |
             +---+---+

Parameters

  [in] | is_flip_horz | A boolean value to indicate whether to flip bitmap in horizontal direction: true means the bitmap will be flipped in horizontal direction, and false means not.
  [in] | is_flip_vert | A boolean value to indicate whether to flip bitmap in vertical direction: true means the bitmap will be flipped in vertical direction, and false means not.
  [in] | clip_rect | The clipping region of destination bitmap. This can be null, which means the whole bitmap. Default value: null.

Returns
  A new bitmap as swapped result.

## ◆ TransformTo()

FSDK.Bitmap.TransformTo | ( | matrix | ,
|  | flag | ,
|  | out_left | ,
|  | out_top | ,
|  | clip_rect |
| ) |  |

Transform current bitmap (as source bitmap) into destination one.

The dimension of returned bitmap always match the dimension of the matrix. If the transformation is to be done in down-sample mode, that would be much faster than not to be done in down-sample mode, especially when transforming big images into small ones. Optionally a clipping region in result bitmap coordinate can be specified to limit the size of result bitmap. The position of left-top corner (in destination coordinate) of the result bitmap would be returned as well. This function can not support the following format:
FSDK.Bitmap.e_DIBCmyk.

Parameters

  [in] | matrix | The transformation matrix.
  [in] | flag | Transform flag. It should be value FSDK.Bitmap.e_Downsample or FSDK.Bitmap.e_Quadratic.
  [out] | out_left | Output parameter that receives x-coordinate of the left-top corner of the result bitmap in destination coordinate.
  [out] | out_top | Output parameter that receives y-coordinate of the left-top corner of the result bitmap in destination coordinate.
  [in] | clip_rect | The clipping region of destination bitmap. It can be null. Default value: null.

Returns
  A new bitmap as transformed result.

## Member Data Documentation

## ◆ e_DIBInvalid

FSDK.Bitmap.e_DIBInvalid
| static

Enumeration for DIB format.

Values of this enumeration should be used alone.Invalid DIB format.

## ◆ e_Downsample

FSDK.Bitmap.e_Downsample
| static

Enumeration for bitmap interpolation flags.

Values of this enumeration can be used alone or in combination.If set, do not do halftone for shrinking or rotating.