Public Member Functions | |
Bitmap (int width, int height, int format, byte[] buffer, int pitch) throws com.foxit.sdk.PDFException | |
Constructor, with parameters. More... | |
Bitmap (Bitmap other) | |
Constructor, with another Bitmap object. More... | |
Bitmap () | |
Constructor, as an empty bitmap object. | |
RectI | calculateBBoxByColor (long backgroud_color) throws com.foxit.sdk.PDFException |
Calculate the bounding box according to the given background color. More... | |
Bitmap | clone (RectI clip_rect) throws com.foxit.sdk.PDFException |
Clone current bitmap, with specified clip rectangle. More... | |
Bitmap | convertFormat (int format, java.lang.Object icc_transform) throws com.foxit.sdk.PDFException |
Convert a bitmap to another specified DIB format. More... | |
RectI | detectBBoxByColorDiffer (int detection_size, int color_differ) throws com.foxit.sdk.PDFException |
Detect the bounding box of content according to the given color difference between content and margin. More... | |
void | fillRect (long color, RectI rect) throws com.foxit.sdk.PDFException |
Fill current bitmap with a specified color. More... | |
Bitmap | flip (boolean is_flip_horz, boolean is_flip_vert) throws com.foxit.sdk.PDFException |
Flip bitmap. More... | |
int | getBpp () throws com.foxit.sdk.PDFException |
Get bitmap bits-per-pixel. More... | |
byte [] | getBuffer () throws com.foxit.sdk.PDFException |
Get bitmap buffer. More... | |
int | getFormat () throws com.foxit.sdk.PDFException |
Get bitmap format. More... | |
int | getHeight () throws com.foxit.sdk.PDFException |
Get bitmap height. More... | |
Bitmap | getMask (RectI clip_rect) throws com.foxit.sdk.PDFException |
Get the mask if bitmap has mask. More... | |
int | getPitch () throws com.foxit.sdk.PDFException |
Get bitmap pitch. More... | |
int | getWidth () throws com.foxit.sdk.PDFException |
Get bitmap width. More... | |
boolean | isEmpty () |
Check whether current object is empty or not. More... | |
Bitmap | stretchTo (int dest_width, int dest_height, int flag, RectI clip_rect) throws com.foxit.sdk.PDFException |
Stretch with different size. More... | |
Bitmap | swapXY (boolean is_flip_horz, boolean is_flip_vert, RectI clip_rect) throws com.foxit.sdk.PDFException |
Swap X,Y coordinations of the bitmap. After being swapped, the image can also be flipped at the same time. More... | |
Bitmap | transformTo (Matrix2D matrix, int flag, java.lang.Integer out_left, java.lang.Integer out_top, RectI clip_rect) throws com.foxit.sdk.PDFException |
Transform current bitmap (as source bitmap) into destination one. More... | |
Static Public Attributes | |
static final int | e_Bicubic = 0x04 |
If set, do bicubic interpolation for stretching or transforming. | |
static final int | e_DIB8bpp = 0x008 |
DIB format: 8bpp format, 256 color RGB bitmap. | |
static final int | e_DIB8bppMask = 0x108 |
DIB format: 8bpp alpha mask. | |
static final int | e_DIBArgb = 0x220 |
DIB format: 32bpp format, with bits order "Blue, Green, Red, Alpha". Blue is in the lowest order. | |
static final int | e_DIBInvalid = 0 |
Invalid DIB format. | |
static final int | e_DIBRgb = 0x018 |
DIB format: 24bpp format, with bits order "Blue, Green, Red". Blue is in the lowest order. | |
static final int | e_DIBRgb32 = 0x020 |
DIB format: 32bpp format, with bits order "Blue, Green, Red, not used". Blue is in the lowest order. | |
static final int | e_DIBRgb565 = 0x565 |
16bpp format, bits order: Red 5 bits, Green 6 bits, Blue 5 bits. Red is the lowest order. | |
static final int | e_Downsample = 0x01 |
If set, do not do halftone for shrinking or rotating. | |
static final int | e_Quadratic = 0x02 |
If set, do interpolation for stretching or transforming. | |
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.
com.foxit.sdk.common.Bitmap.Bitmap | ( | int | width, |
int | height, | ||
int | format, | ||
byte [] | buffer, | ||
int | pitch | ||
) | throws com.foxit.sdk.PDFException |
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.
width | Width of bitmap, in pixels. This should be above 0. |
height | Height of bitmap, in pixels. This should be above 0. |
format | Bitmap format type. Please refer to values starting from e_DIBRgb and this should be one of these values except e_DIBInvalid. |
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. |
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. |
com.foxit.sdk.common.Bitmap.Bitmap | ( | Bitmap | other | ) |
RectI com.foxit.sdk.common.Bitmap.calculateBBoxByColor | ( | long | backgroud_color | ) | throws com.foxit.sdk.PDFException |
Calculate the bounding box according to the given background color.
This function can support the following formats: e_DIB8bppMask, e_DIB8bpp, e_DIBRgb, e_DIBRgb32, e_DIBArgb.
backgroud_color | A valid background color. Format: 0xAARRGGBB. |
Bitmap com.foxit.sdk.common.Bitmap.clone | ( | RectI | clip_rect | ) | throws com.foxit.sdk.PDFException |
Clone current bitmap, with specified clip rectangle.
clip_rect | The clipping region in current bitmap to specify the region to be cloned. For bitmap format 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. |
Bitmap com.foxit.sdk.common.Bitmap.convertFormat | ( | int | format, |
java.lang.Object | icc_transform | ||
) | throws com.foxit.sdk.PDFException |
Convert a bitmap to another specified DIB format.
format | New bitmap format type. It should be one of following values: e_DIB8bppMask, e_DIB8bpp, e_DIBRgb, e_DIBRgb32, e_DIBArgb. e_DIBRgb565. |
icc_transform | The color mapping context for source format to destination format. It can be null, which means not use the color mapping. |
RectI com.foxit.sdk.common.Bitmap.detectBBoxByColorDiffer | ( | int | detection_size, |
int | color_differ | ||
) | throws com.foxit.sdk.PDFException |
Detect the bounding box of content according to the given color difference between content and margin.
This function can support the following formats: e_DIB8bppMask, e_DIB8bpp, e_DIBRgb, e_DIBRgb32, e_DIBArgb.
detection_size | Detection size to analyze background. |
color_differ | Color difference used to detect margin. The value should be between 0 and 255, and the suggested value is 64. |
void com.foxit.sdk.common.Bitmap.fillRect | ( | long | color, |
RectI | rect | ||
) | throws com.foxit.sdk.PDFException |
Fill current bitmap with a specified color.
color | A color value which is used to fill bitmap. Format: 0xAARRGGBB |
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. |
Bitmap com.foxit.sdk.common.Bitmap.flip | ( | boolean | is_flip_horz, |
boolean | is_flip_vert | ||
) | throws com.foxit.sdk.PDFException |
Flip bitmap.
This function can support following formats: e_DIB8bppMask, e_DIB8bpp, e_DIBRgb, e_DIBRgb32, e_DIBArgb.
is_flip_horz | A boolean value to indicate whether to flipping bitmap in horizontal direction: true means a bitmap will be flipped in horizontal direction, and false means not. |
is_flip_vert | A boolean value to indicate whether to flipping bitmap in vertical direction. true means a bitmap will be flipped in vertical direction, and false means not. |
int com.foxit.sdk.common.Bitmap.getBpp | ( | ) | throws com.foxit.sdk.PDFException |
Get bitmap bits-per-pixel.
byte[] com.foxit.sdk.common.Bitmap.getBuffer | ( | ) | throws com.foxit.sdk.PDFException |
int com.foxit.sdk.common.Bitmap.getFormat | ( | ) | throws com.foxit.sdk.PDFException |
Get bitmap format.
int com.foxit.sdk.common.Bitmap.getHeight | ( | ) | throws com.foxit.sdk.PDFException |
Get bitmap height.
Bitmap com.foxit.sdk.common.Bitmap.getMask | ( | RectI | clip_rect | ) | throws com.foxit.sdk.PDFException |
Get the mask if bitmap has mask.
clip_rect | The clipping region of current bitmap (as source bitmap). It can be null. |
int com.foxit.sdk.common.Bitmap.getPitch | ( | ) | throws com.foxit.sdk.PDFException |
Get bitmap pitch.
int com.foxit.sdk.common.Bitmap.getWidth | ( | ) | throws com.foxit.sdk.PDFException |
Get bitmap width.
boolean com.foxit.sdk.common.Bitmap.isEmpty | ( | ) |
Check whether current object is empty or not.
When the current object is empty, that means current object is useless.
Bitmap com.foxit.sdk.common.Bitmap.stretchTo | ( | int | dest_width, |
int | dest_height, | ||
int | flag, | ||
RectI | clip_rect | ||
) | throws com.foxit.sdk.PDFException |
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.
dest_width | The width of the destination bitmap. |
dest_height | The height of the destination bitmap. |
flag | Stretch flag, It should be value e_Downsample or e_Quadratic. |
clip_rect | The clipping region of destination bitmap. It can be null. |
Bitmap com.foxit.sdk.common.Bitmap.swapXY | ( | boolean | is_flip_horz, |
boolean | is_flip_vert, | ||
RectI | clip_rect | ||
) | throws com.foxit.sdk.PDFException |
Swap X,Y coordinations of the bitmap. After being swapped, the image can also be flipped at the same time.
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 | +---+---+
is_flip_horz | A boolean value to indicate whether to flipping bitmap in horizontal direction: true means the bitmap will be flipped in horizontal direction, and false means not. |
is_flip_vert | A boolean value to indicate whether to flipping bitmap in vertical direction: true means the bitmap will be flipped in vertical direction, and false means not. |
clip_rect | The clipping region of destination bitmap. This can be null, which means the whole bitmap. |
Bitmap com.foxit.sdk.common.Bitmap.transformTo | ( | Matrix2D | matrix, |
int | flag, | ||
java.lang.Integer | out_left, | ||
java.lang.Integer | out_top, | ||
RectI | clip_rect | ||
) | throws com.foxit.sdk.PDFException |
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.
matrix | The transformation matrix. |
flag | Transform flag. It should be value e_Downsample or e_Quadratic. |
out_left | Output parameter that receives x-coordinate of the left-top corner of the result bitmap in destination coordinate. |
out_top | Output parameter that receives y-coordinate of the left-top corner of the result bitmap in destination coordinate. |
clip_rect | The clipping region of destination bitmap. It can be null. |