Foxit PDF SDK
|
Public Types | |
enum | DIBFormat { e_DIBInvalid = 0, e_DIB1bpp = 0x001, e_DIBRgb = 0x018, e_DIBRgb32 = 0x020, e_DIBArgb = 0x220, e_DIBCmyk = 0x420, e_DIB8bppMask = 0x108, e_DIB8bpp = 0x008, e_DIB8bppGray = 0x1008, e_DIBAbgr = 0x222, e_DIBRgb565 = 0x565 } |
Enumeration for DIB format. More... | |
enum | InterpolationFlag { e_Downsample = 0x01, e_Quadratic = 0x02, e_Bicubic = 0x04 } |
Enumeration for bitmap interpolation flags. More... | |
Public Member Functions | |
Bitmap (int width, int height, DIBFormat format, uint8 *buffer=0, int pitch=0) | |
Constructor, with parameters. More... | |
Bitmap (const Bitmap &other) | |
Constructor, with another bitmap object. More... | |
Bitmap () | |
Constructor, as an empty bitmap object. | |
~Bitmap () | |
Destructor. | |
RectI | CalculateBBoxByColor (ARGB backgroud_color) |
Calculate the bounding box according to the given background color. More... | |
Bitmap | Clone (const RectI *clip_rect=0) const |
Clone current bitmap, with specified clip rectangle. More... | |
Bitmap & | ConvertFormat (DIBFormat format, void *icc_transform=0) |
Convert a bitmap to another specified DIB format. More... | |
RectI | DetectBBoxByColorDiffer (int detection_size, int color_differ=64) |
Detect the bounding box of content according to the given color difference between content and margin. More... | |
void | FillRect (ARGB color, const RectI *rect=0) |
Fill current bitmap with a specified color. More... | |
Bitmap | Flip (bool is_flip_horz, bool is_flip_vert) |
Flip bitmap. More... | |
int | GetBpp () const |
Get bitmap bits-per-pixel. More... | |
const uint8 * | GetBuffer () const |
Get bitmap buffer. More... | |
DIBFormat | GetFormat () const |
Get bitmap format. More... | |
int | GetHeight () const |
Get bitmap height. More... | |
Bitmap | GetMask (const RectI *clip_rect=0) |
Get the mask if bitmap has mask. More... | |
int | GetPitch () const |
Get bitmap pitch. More... | |
int | GetWidth () const |
Get bitmap width. More... | |
bool | IsEmpty () const |
Check whether current object is empty or not. More... | |
bool | operator != (const Bitmap &other) const |
Not equal operator. More... | |
Bitmap & | operator= (const Bitmap &other) |
Assign operator. More... | |
bool | operator== (const Bitmap &other) const |
Equal operator. More... | |
Bitmap | StretchTo (int dest_width, int dest_height, InterpolationFlag flag, const RectI *clip_rect=0) |
Stretch with different size. More... | |
Bitmap | SwapXY (bool is_flip_horz, bool is_flip_vert, const RectI *clip_rect=0) |
Swap X,Y coordinations of the bitmap. After being swapped, the image can also be flipped at the same time. More... | |
Bitmap | TransformTo (const Matrix &matrix, InterpolationFlag flag, int &out_left, int &out_top, const RectI *clip_rect=0) |
Transform current bitmap (as source bitmap) into destination one. More... | |
![]() | |
FS_HANDLE | Handle () const |
Get the handle of current object. More... | |
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.
Enumeration for DIB format.
Values of this enumeration should be used alone.
Enumeration for bitmap interpolation flags.
Values of this enumeration can be used alone or in combination.
foxit::common::Bitmap::Bitmap | ( | int | width, |
int | height, | ||
DIBFormat | format, | ||
uint8 * | buffer = 0 , |
||
int | pitch = 0 |
||
) |
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:
[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 Bitmap::e_DIBRgb and this should be one of these values except 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. |
foxit::common::Bitmap::Bitmap | ( | const Bitmap & | other | ) |
Constructor, with another bitmap object.
[in] | other | Another bitmap object. |
Calculate the bounding box according to the given background color.
This function can support the following formats:
Bitmap::e_DIB8bppMask, Bitmap::e_DIB8bpp, Bitmap::e_DIBRgb, Bitmap::e_DIBRgb32, Bitmap::e_DIBArgb.
[in] | backgroud_color | A valid background color. Format: 0xAARRGGBB. |
Clone current bitmap, with specified clip rectangle.
[in] | clip_rect | The clipping region in current bitmap to specify the region to be cloned.
|
Convert a bitmap to another specified DIB format.
[in] | format | New bitmap format type. It should be one of following values: Bitmap::e_DIB8bppMask, Bitmap::e_DIB8bpp, Bitmap::e_DIBRgb, Bitmap::e_DIBRgb32, Bitmap::e_DIBArgb. 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. |
RectI foxit::common::Bitmap::DetectBBoxByColorDiffer | ( | int | detection_size, |
int | color_differ = 64 |
||
) |
Detect the bounding box of content according to the given color difference between content and margin.
This function can support the following formats:
Bitmap::e_DIB8bppMask, Bitmap::e_DIB8bpp, Bitmap::e_DIBRgb, Bitmap::e_DIBRgb32, Bitmap::e_DIBArgb.
[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. |
Fill current bitmap with a specified color.
This function can not support the following format:
Bitmap::e_DIBCmyk.
[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. |
Bitmap foxit::common::Bitmap::Flip | ( | bool | is_flip_horz, |
bool | is_flip_vert | ||
) |
Flip bitmap.
This function can support following formats:
Bitmap::e_DIB8bppMask, Bitmap::e_DIB8bpp, Bitmap::e_DIBRgb, Bitmap::e_DIBRgb32, Bitmap::e_DIBArgb.
[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. |
int foxit::common::Bitmap::GetBpp | ( | ) | const |
Get bitmap bits-per-pixel.
const uint8* foxit::common::Bitmap::GetBuffer | ( | ) | const |
Get bitmap buffer.
Bitmap data are organized in scan-lines, from top to down.
DIBFormat foxit::common::Bitmap::GetFormat | ( | ) | const |
Get bitmap format.
int foxit::common::Bitmap::GetHeight | ( | ) | const |
Get bitmap height.
Get the mask if bitmap has mask.
[in] | clip_rect | The clipping region of current bitmap (as source bitmap). It can be NULL. Default value: NULL. |
int foxit::common::Bitmap::GetPitch | ( | ) | const |
Get bitmap pitch.
int foxit::common::Bitmap::GetWidth | ( | ) | const |
Get bitmap width.
bool foxit::common::Bitmap::IsEmpty | ( | ) | const |
Check whether current object is empty or not.
When the current object is empty, that means current object is useless.
bool foxit::common::Bitmap::operator != | ( | const Bitmap & | other | ) | const |
Not equal operator.
[in] | other | Another bitmap object. This function will check if current object is not equal to this one. |
Assign operator.
[in] | other | Another bitmap object, whose value would be assigned to current object. |
bool foxit::common::Bitmap::operator== | ( | const Bitmap & | other | ) | const |
Equal operator.
[in] | other | Another bitmap object. This function will check if current object is equal to this one. |
Bitmap foxit::common::Bitmap::StretchTo | ( | int | dest_width, |
int | dest_height, | ||
InterpolationFlag | flag, | ||
const RectI * | clip_rect = 0 |
||
) |
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:
Bitmap::e_DIBCmyk.
[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 Bitmap::e_Downsample or Bitmap::e_Quadratic. |
[in] | clip_rect | The clipping region of destination bitmap. It can be NULL. Default value: NULL. |
Bitmap foxit::common::Bitmap::SwapXY | ( | bool | is_flip_horz, |
bool | is_flip_vert, | ||
const RectI * | clip_rect = 0 |
||
) |
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:
Bitmap::e_DIB8bppMask, Bitmap::e_DIB8bpp, Bitmap::e_DIBRgb, Bitmap::e_DIBRgb32, 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 | +---+---+
[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. |
Bitmap foxit::common::Bitmap::TransformTo | ( | const Matrix & | matrix, |
InterpolationFlag | flag, | ||
int & | out_left, | ||
int & | out_top, | ||
const RectI * | clip_rect = 0 |
||
) |
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:
Bitmap::e_DIBCmyk.
[in] | matrix | The transformation matrix. |
[in] | flag | Transform flag. It should be value Bitmap::e_Downsample or 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. |