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

Instance Methods

(FSRectI *) - calculateBBoxByColor:
 Calculate the bounding box according to the given background color.
More...
 
(FSBitmap *) - clone:
 Clone current bitmap, with specified clip rectangle.
More...
 
(FSBitmap *) - convertFormat:icc_transform:
 Convert a bitmap to another specified DIB format.
More...
 
(FSRectI *) - detectBBoxByColorDiffer:color_differ:
 Detect the bounding box of content according to the given color difference between content and margin.
More...
 
(void) - fillRect:rect:
 Fill current bitmap with a specified color.
More...
 
(FSBitmap *) - flip:is_flip_vert:
 Flip bitmap.
More...
 
(int) - getBpp
 Get bitmap bits-per-pixel.
More...
 
(NSData *) - getBuffer
 Get bitmap buffer.
More...
 
(FSBitmapDIBFormat- getFormat
 Get bitmap format.
More...
 
(int) - getHeight
 Get bitmap height.
More...
 
(FSBitmap *) - getMask:
 Get the mask if bitmap has mask.
More...
 
(int) - getPitch
 Get bitmap pitch.
More...
 
(int) - getWidth
 Get bitmap width.
More...
 
(id) - init
 Constructor, as an empty bitmap object.

 
(id) - initWithOther:
 Constructor, with another bitmap object.
More...
 
(id) - initWithWidth:height:format:buffer:pitch:
 Constructor, with parameters.
More...
 
(BOOL) - isEmpty
 Check whether current object is empty or not.
More...
 
(FSBitmap *) - stretchTo:dest_height:flag:clip_rect:
 Stretch with different size.
More...
 
(FSBitmap *) - swapXY: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...
 
(FSBitmap *) - transformTo:flag:out_left:out_top:clip_rect:
 Transform current bitmap (as source bitmap) into destination one.
More...
 

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.

Method Documentation

◆ calculateBBoxByColor:()

- (FSRectI *) calculateBBoxByColor: (unsigned int)  backgroud_color

Calculate the bounding box according to the given background color.

This function can support the following formats:
FSBitmapDIB8bppMask, FSBitmapDIB8bpp, FSBitmapDIBRgb, FSBitmapDIBRgb32, FSBitmapDIBArgb.

Parameters
[in]backgroud_colorA valid background color. Format: 0xAARRGGBB.
Returns
The rectangle of bounding box for content.

◆ clone:()

- (FSBitmap *) clone: (FSRectI*)  clip_rect

Clone current bitmap, with specified clip rectangle.

Parameters
[in]clip_rectThe clipping region in current bitmap to specify the region to be cloned.
  • For bitmap format FSBitmapDIBRgb565, currently only support to clone the whole bitmap, so this should always be nil.
  • For rest format, this can be either nil or valid. If this is nil, that means to clone the whole bitmap. If this is not nil, it specifies a clipping region in bitmap to be cloned and the cloned bitmap will have the same size as the clipping region.

Returns
A new bitmap as cloned result.

◆ convertFormat:icc_transform:()

- (FSBitmap *) convertFormat: (FSBitmapDIBFormat format
icc_transform: (NSData *)  icc_transform 

Convert a bitmap to another specified DIB format.

Parameters
[in]formatNew bitmap format type. It should be one of following values:
FSBitmapDIB8bppMask, FSBitmapDIB8bpp, FSBitmapDIBRgb, FSBitmapDIBRgb32, FSBitmapDIBArgb. FSBitmapDIBRgb565.
[in]icc_transformThe color mapping context for source format to destination format. It can be nil, which means not use the color mapping.
Returns
The converted bitmap.

◆ detectBBoxByColorDiffer:color_differ:()

- (FSRectI *) detectBBoxByColorDiffer: (int)  detection_size
color_differ: (int)  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:
FSBitmapDIB8bppMask, FSBitmapDIB8bpp, FSBitmapDIBRgb, FSBitmapDIBRgb32, FSBitmapDIBArgb.

Parameters
[in]detection_sizeDetection size to analyze background.
[in]color_differColor difference used to detect margin. The value should be between 0 and 255, and the suggested value is 64.
Returns
The rectangle of bounding box for content.

◆ fillRect:rect:()

- (void) fillRect: (unsigned int)  color
rect: (FSRectI*)  rect 

Fill current bitmap with a specified color.

Parameters
[in]colorA color value which is used to fill bitmap. Format: 0xAARRGGBB
[in]rectA rectangle that represents a region in bitmap to specify where the color will be filled. This can be nil, which means to fill the whole bitmap.
Returns
None.

◆ flip:is_flip_vert:()

- (FSBitmap *) flip: (BOOL)  is_flip_horz
is_flip_vert: (BOOL)  is_flip_vert 

Flip bitmap.

This function can support following formats:
FSBitmapDIB8bppMask, FSBitmapDIB8bpp, FSBitmapDIBRgb, FSBitmapDIBRgb32, FSBitmapDIBArgb.

Parameters
[in]is_flip_horzA boolean value to indicate whether to flip bitmap in horizontal direction: YES means a bitmap will be flipped in horizontal direction, and NO means not.
[in]is_flip_vertA boolean value to indicate whether to flip bitmap in vertical direction. YES means a bitmap will be flipped in vertical direction, and NO means not.
Returns
A new bitmap as flipped result.

◆ getBpp()

- (int) getBpp

Get bitmap bits-per-pixel.

Returns
Bitmap bits-per-pixel value.

◆ getBuffer()

- (NSData *) getBuffer

Get bitmap buffer.

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

Returns
Bitmap buffer.

◆ getFormat()

- (FSBitmapDIBFormat) getFormat

Get bitmap format.

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

◆ getHeight()

- (int) getHeight

Get bitmap height.

Returns
Bitmap height.

◆ getMask:()

- (FSBitmap *) getMask: (FSRectI*)  clip_rect

Get the mask if bitmap has mask.

Parameters
[in]clip_rectThe clipping region of current bitmap (as source bitmap). It can be nil.
Returns
A new bitmap as mask bitmap. If the return value of function FSBitmap::isEmpty for the returned bitmap object is YES, that means current bitmap does not have mask.

◆ getPitch()

- (int) getPitch

Get bitmap pitch.

Returns
Bitmap pitch.

◆ getWidth()

- (int) getWidth

Get bitmap width.

Returns
Bitmap width.

◆ initWithOther:()

- (id) initWithOther: (FSBitmap*)  other

Constructor, with another bitmap object.

Parameters
[in]otherAnother bitmap object.

◆ initWithWidth:height:format:buffer:pitch:()

- (id) initWithWidth: (int)  width
height: (int)  height
format: (FSBitmapDIBFormat format
buffer: (NSData *)  buffer
pitch: (int)  pitch 

Constructor, with parameters.

If parameter buffer is not nil, it should be initialized by application; if parameter buffer is nil, 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.


Parameters
[in]widthWidth of bitmap, in pixels. This should be above 0.
[in]heightHeight of bitmap, in pixels. This should be above 0.
[in]formatBitmap format type. Please refer to values starting from FSBitmapDIBRgb and this should be one of these values except FSBitmapDIBInvalid.
[in]bufferA buffer that specifies bitmap data.
If it is not nil, 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 nil, a new bitmap buffer will be created internally.
[in]pitchThe number of bytes for each scan line. This is useful only when parameter buffer is not nil. If this value is 0, 4-byte alignment is assumed.

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

◆ stretchTo:dest_height:flag:clip_rect:()

- (FSBitmap *) stretchTo: (int)  dest_width
dest_height: (int)  dest_height
flag: (FSBitmapInterpolationFlag flag
clip_rect: (FSRectI*)  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.

Parameters
[in]dest_widthThe width of the destination bitmap.
[in]dest_heightThe height of the destination bitmap.
[in]flagStretch flag, It should be value FSBitmapDownsample or FSBitmapQuadratic.
[in]clip_rectThe clipping region of destination bitmap. It can be nil.
Returns
A new bitmap as stretched result.

◆ swapXY:is_flip_vert:clip_rect:()

- (FSBitmap *) swapXY: (BOOL)  is_flip_horz
is_flip_vert: (BOOL)  is_flip_vert
clip_rect: (FSRectI*)  clip_rect 

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 = NO, parameter is_flip_vert = NO:

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

if parameter is_flip_horz = YES, parameter is_flip_vert = NO:

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

if parameter is_flip_horz = NO, parameter is_flip_vert = YES:

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

if parameter is_flip_horz = YES, parameter is_flip_vert = YES:

         +---+---+
         | 4 | 2 |
         +---+---+
         | 3 | 1 |
         +---+---+
         
Parameters
[in]is_flip_horzA boolean value to indicate whether to flip bitmap in horizontal direction: YES means the bitmap will be flipped in horizontal direction, and NO means not.
[in]is_flip_vertA boolean value to indicate whether to flip bitmap in vertical direction: YES means the bitmap will be flipped in vertical direction, and NO means not.
[in]clip_rectThe clipping region of destination bitmap. This can be nil, which means the whole bitmap.
Returns
A new bitmap as swapped result.

◆ transformTo:flag:out_left:out_top:clip_rect:()

- (FSBitmap *) transformTo: (FSMatrix2D*)  matrix
flag: (FSBitmapInterpolationFlag flag
out_left: (int *)  out_left
out_top: (int *)  out_top
clip_rect: (FSRectI*)  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.

Parameters
[in]matrixThe transformation matrix.
[in]flagTransform flag. It should be value FSBitmapDownsample or FSBitmapQuadratic.
[out]out_leftOutput parameter that receives x-coordinate of the left-top corner of the result bitmap in destination coordinate.
[out]out_topOutput parameter that receives y-coordinate of the left-top corner of the result bitmap in destination coordinate.
[in]clip_rectThe clipping region of destination bitmap. It can be nil.
Returns
A new bitmap as transformed result.