Foxit PDF SDK
fs_image.h
Go to the documentation of this file.
1 
15 #ifndef FS_IMAGE_H_
16 #define FS_IMAGE_H_
17 
18 #include "common/fs_common.h"
19 #include "common/file/fs_file.h"
20 
26 namespace foxit {
30 namespace common {
36 class Bitmap FS_FINAL : public Base {
37  public:
43  typedef enum _DIBFormat {
47  e_DIB1bpp = 0x001,
49  e_DIBRgb = 0x018,
51  e_DIBRgb32 = 0x020,
53  e_DIBArgb = 0x220,
55  e_DIBCmyk = 0x420,
57  e_DIB8bppMask = 0x108,
59  e_DIB8bpp = 0x008,
61  e_DIB8bppGray = 0x1008,
63  e_DIBAbgr = 0x222,
65  e_DIBRgb565 = 0x565
66  } DIBFormat;
67 
73  typedef enum _InterpolationFlag {
75  e_Downsample = 0x01,
77  e_Quadratic = 0x02,
79  e_Bicubic = 0x04
81 
82 
112  Bitmap(int width, int height, DIBFormat format, uint8* buffer = NULL, int pitch = 0);
118  Bitmap(const Bitmap& other);
120  Bitmap();
121 
123  ~Bitmap();
124 
132  Bitmap& operator = (const Bitmap& other);
140  bool operator == (const Bitmap& other) const;
148  bool operator != (const Bitmap& other) const;
149 
157  bool IsEmpty() const;
158 
177  Bitmap Clone(const RectI* clip_rect = NULL) const;
178 
184  int GetWidth() const;
190  int GetHeight() const;
196  int GetPitch() const;
202  int GetBpp() const;
210  const uint8* GetBuffer() const;
217  DIBFormat GetFormat() const;
218 
230  void FillRect(ARGB color, const RectI* rect = NULL);
231 
244  Bitmap& ConvertFormat(DIBFormat format, void* icc_transform = NULL);
245 
258  RectI CalculateBBoxByColor(ARGB backgroud_color);
259 
274  RectI DetectBBoxByColorDiffer(int detection_size, int color_differ = 64);
275 
338  Bitmap SwapXY(bool is_flip_horz, bool is_flip_vert, const RectI* clip_rect = NULL);
339 
357  Bitmap Flip(bool is_flip_horz, bool is_flip_vert);
358 
379  Bitmap StretchTo(int dest_width, int dest_height, InterpolationFlag flag,
380  const RectI* clip_rect = NULL);
381 
406  Bitmap TransformTo(const Matrix& matrix, InterpolationFlag flag,
407  int& out_left, int &out_top, const RectI* clip_rect = NULL);
408 
418  Bitmap GetMask(const RectI* clip_rect = NULL);
419 
430 
431  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
432  explicit Bitmap(FS_HANDLE handle);
433 };
434 
459 class Image FS_FINAL : public Base {
460  public:
466  typedef enum _Type {
468  e_Unknown = -1,
474  e_None = 0,
476  e_BMP = 1,
478  e_JPG = 2,
480  e_PNG = 3,
482  e_GIF = 4,
484  e_TIF = 5,
486  e_JPX = 6,
491  e_JBIG2 = 8,
496  e_WEBP = 9
497  } Type;
498 
504  typedef enum _Orientation {
523  } Orientation;
524 
525 
532  Image();
533 
539  explicit Image(const char* path);
540 
546  explicit Image(const wchar_t* path);
547 
555  explicit Image(const void* buffer, size_t length);
556 
563  explicit Image(foxit::common::file::ReaderCallback* file_read);
564 
566  ~Image();
567 
573  Image(const Image& other);
574 
582  Image& operator = (const Image& other);
583 
591  bool IsEmpty() const;
592 
600  bool operator == (const Image& other) const;
608  bool operator != (const Image& other) const;
609 
618  Type GetType() const;
619 
627  int GetWidth() const;
628 
636  int GetHeight() const;
637 
645  int GetFrameCount() const;
646 
664  Bitmap GetFrameBitmap(int index) const;
665 
675  int GetXDPI() const;
676 
686  int GetYDPI() const;
687 
708  bool AddFrame(const Bitmap& bitmap);
709 
721  void SetDPIs(int x_dpi, int y_dpi);
722 
752  bool SaveAs(const char* file_path);
753 
783  bool SaveAs(const wchar_t* file_path);
784 
815  bool SaveAs(foxit::common::file::StreamCallback* file, const wchar_t* file_extension);
816 
825  Orientation GetOrientation() const;
826 
827  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
828  explicit Image(FS_HANDLE handle);
829 
830 };
831 } // namespace common
832 } // namespace foxit
833 #endif // FS_IMAGE_H_
834 
bool operator==(const Bitmap &other) const
Equal operator.
No orientation.
Definition: fs_image.h:506
DIB format: 32bpp CMYK format, with bits order "Cyan, Magenta, Yellow, Black". Cyan is in the lowest ...
Definition: fs_image.h:55
Bitmap ConvertToMono()
Converts bitmap to 1-bit monochrome format.
DIB format: 1bpp format, two color RGB bitmap.It does not support format conversion between bitmaps.
Definition: fs_image.h:47
int GetBpp() const
Get bitmap bits-per-pixel.
Unknown image type.
Definition: fs_image.h:468
Orientation GetOrientation() const
Get image orientation.
Definition: fs_image.h:36
Image type is PNG.
Definition: fs_image.h:480
Bitmap GetFrameBitmap(int index) const
Get a frame bitmap, specified by index.
bool IsEmpty() const
Check whether current object is empty or not.
Image()
Constructor.
DIB format: 32bpp format, with bits order "Blue, Green, Red, Alpha". Blue is in the lowest order.
Definition: fs_image.h:53
bool operator !=(const Bitmap &other) const
Not equal operator.
First rotate 90 in clockwise direction and then flip horizontal.
Definition: fs_image.h:516
DIB format: 8bpp alpha mask.
Definition: fs_image.h:57
FX_UINT8 uint8
8-bit unsigned integer.
Definition: fs_basictypes.h:203
Bitmap & operator=(const Bitmap &other)
Assign operator.
DIB format: 24bpp format, with bits order "Blue, Green, Red". Blue is in the lowest order.
Definition: fs_image.h:49
First rotate 90 in counter-clockwise direction and then flip horizontal.
Definition: fs_image.h:520
Header file for file operation related definitions and functions.
File reading interface.
Definition: fx_stream.h:587
DIBFormat
Enumeration for DIB format.
Definition: fs_image.h:43
Bitmap & ConvertFormat(DIBFormat format, void *icc_transform=0)
Convert a bitmap to another specified DIB format.
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.
int GetHeight() const
Get image height.
Image type is GIF.
Definition: fs_image.h:482
Bitmap Clone(const RectI *clip_rect=0) const
Clone current bitmap, with specified clip rectangle.
~Image()
Destructor.
DIBFormat GetFormat() const
Get bitmap format.
Image type is JPX or JPEG-2000.
Definition: fs_image.h:486
Image type is webp.
Definition: fs_image.h:496
bool AddFrame(const Bitmap &bitmap)
Add a bitmap as a frame. (Unsupported DIB formats: Bitmap::e_DIBRgb565 and Bitmap::e_DIB8bppMask)
DIB format: 8bpp format, 256 color GrayScale bitmap.
Definition: fs_image.h:61
16bpp format, bits order: Red 5 bits, Green 6 bits, Blue 5 bits. Red is the lowest order.
Definition: fs_image.h:65
Bitmap StretchTo(int dest_width, int dest_height, InterpolationFlag flag, const RectI *clip_rect=0)
Stretch with different size.
bool SaveAs(const char *file_path)
Save current image as an image file.
Bitmap()
Constructor, as an empty bitmap object.
Image & operator=(const Image &other)
Assign operator.
DIB format: 32bpp format, with bits order "Red, Green, Blue, Alpha". Red is in the lowest order.
Definition: fs_image.h:63
RectI CalculateBBoxByColor(ARGB backgroud_color)
Calculate the bounding box according to the given background color.
Rotate 90 degrees in counter-clockwise direction.
Definition: fs_image.h:522
Rotate 90 degrees in clockwise direction.
Definition: fs_image.h:518
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 ...
uint32 ARGB
ARGB color type, 32 bits, ((b) | ((g) << 8) | ((r) << 16)) | ((a) << 24)
Definition: fs_basictypes.h:209
Rotate 180 degrees in clockwise direction.
Definition: fs_image.h:512
DIB format: 32bpp format, with bits order "Blue, Green, Red, not used". Blue is in the lowest order.
Definition: fs_image.h:51
File stream interface, reading & writing.
Definition: fx_stream.h:692
Normal orientation.
Definition: fs_image.h:508
void FillRect(ARGB color, const RectI *rect=0)
Fill current bitmap with a specified color.
Invalid DIB format.
Definition: fs_image.h:45
If set, do not do halftone for shrinking or rotating.
Definition: fs_image.h:75
Type GetType() const
Get image type.
bool operator !=(const Image &other) const
Not equal operator.
bool IsEmpty() const
Check whether current object is empty or not.
~Bitmap()
Destructor.
DIB format: 8bpp format, 256 color RGB bitmap.
Definition: fs_image.h:59
int GetWidth() const
Get bitmap width.
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:213
Header file for common definitions and classes.
Flip Vertical.
Definition: fs_image.h:514
int GetFrameCount() const
Get frame count.
Definition: fx_coordinates.h:596
If set, do interpolation for stretching or transforming.
Definition: fs_image.h:77
If set, do bicubic interpolation for stretching or transforming.
Definition: fs_image.h:79
Definition: fs_basictypes.h:451
int GetWidth() const
Get image width.
int GetHeight() const
Get bitmap height.
Type
Enumeration for image type.
Definition: fs_image.h:466
const uint8 * GetBuffer() const
Get bitmap buffer.
Foxit namespace.
Definition: fs_taggedpdf.h:27
Image type is TIF or TIFF.
Definition: fs_image.h:484
Bitmap Flip(bool is_flip_horz, bool is_flip_vert)
Flip bitmap.
int GetXDPI() const
Get DPI for X-axis.
Orientation
Enumeration for image orientation.
Definition: fs_image.h:504
Bitmap GetMask(const RectI *clip_rect=0)
Get the mask if bitmap has mask.
Flip Horizontal.
Definition: fs_image.h:510
int GetPitch() const
Get bitmap pitch.
int GetYDPI() const
Get DPI for Y-axis.
#define NULL
The null-pointer value.
Definition: fx_system.h:792
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...
Not have image type yet.
Definition: fs_image.h:474
Definition: fx_coordinates.h:1076
void SetDPIs(int x_dpi, int y_dpi)
Set DPI for X-axis and Y-axis.
InterpolationFlag
Enumeration for bitmap interpolation flags.
Definition: fs_image.h:73
Image type is JPG or JPEG.
Definition: fs_image.h:478
Definition: fs_image.h:459
Image type is BMP.
Definition: fs_image.h:476
bool operator==(const Image &other) const
Equal operator.
Image type is JBIG2.
Definition: fs_image.h:491