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 
108  Bitmap(int width, int height, DIBFormat format, uint8* buffer = NULL, int pitch = 0);
114  Bitmap(const Bitmap& other);
116  Bitmap();
117 
119  ~Bitmap();
120 
128  Bitmap& operator = (const Bitmap& other);
136  bool operator == (const Bitmap& other) const;
144  bool operator != (const Bitmap& other) const;
145 
153  bool IsEmpty() const;
154 
173  Bitmap Clone(const RectI* clip_rect = NULL) const;
174 
180  int GetWidth() const;
186  int GetHeight() const;
192  int GetPitch() const;
198  int GetBpp() const;
206  const uint8* GetBuffer() const;
213  DIBFormat GetFormat() const;
214 
227  void FillRect(ARGB color, const RectI* rect = NULL);
228 
241  Bitmap& ConvertFormat(DIBFormat format, void* icc_transform = NULL);
242 
255  RectI CalculateBBoxByColor(ARGB backgroud_color);
256 
271  RectI DetectBBoxByColorDiffer(int detection_size, int color_differ = 64);
272 
335  Bitmap SwapXY(bool is_flip_horz, bool is_flip_vert, const RectI* clip_rect = NULL);
336 
354  Bitmap Flip(bool is_flip_horz, bool is_flip_vert);
355 
376  Bitmap StretchTo(int dest_width, int dest_height, InterpolationFlag flag,
377  const RectI* clip_rect = NULL);
378 
403  Bitmap TransformTo(const Matrix& matrix, InterpolationFlag flag,
404  int& out_left, int &out_top, const RectI* clip_rect = NULL);
405 
415  Bitmap GetMask(const RectI* clip_rect = NULL);
416 
417  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
418  explicit Bitmap(FS_HANDLE handle);
419 };
420 
445 class Image FS_FINAL : public Base {
446  public:
452  typedef enum _Type {
454  e_Unknown = -1,
460  e_None = 0,
462  e_BMP = 1,
464  e_JPG = 2,
466  e_PNG = 3,
468  e_GIF = 4,
470  e_TIF = 5,
472  e_JPX = 6,
478  } Type;
479 
480 
487  Image();
488 
494  explicit Image(const char* path);
495 
501  explicit Image(const wchar_t* path);
502 
510  explicit Image(const void* buffer, size_t length);
511 
518  explicit Image(foxit::common::file::ReaderCallback* file_read);
519 
521  ~Image();
522 
528  Image(const Image& other);
529 
537  Image& operator = (const Image& other);
538 
546  bool IsEmpty() const;
547 
555  bool operator == (const Image& other) const;
563  bool operator != (const Image& other) const;
564 
573  Type GetType() const;
574 
582  int GetWidth() const;
583 
591  int GetHeight() const;
592 
600  int GetFrameCount() const;
601 
619  Bitmap GetFrameBitmap(int index) const;
620 
630  int GetXDPI() const;
631 
641  int GetYDPI() const;
642 
663  bool AddFrame(const Bitmap& bitmap);
664 
676  void SetDPIs(int x_dpi, int y_dpi);
677 
704  bool SaveAs(const char* file_path);
705 
732  bool SaveAs(const wchar_t* file_path);
733 
761  bool SaveAs(foxit::common::file::StreamCallback* file, const wchar_t* file_extension);
762 
763  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
764  explicit Image(FS_HANDLE handle);
765 };
766 } // namespace common
767 } // namespace foxit
768 #endif // FS_IMAGE_H_
769 
bool operator==(const Bitmap &other) const
Equal operator.
DIB format: 32bpp CMYK format, with bits order "Cyan, Magenta, Yellow, Black". Cyan is in the lowest ...
Definition: fs_image.h:55
DIB format: 1bpp format, two color RGB bitmap.It does not support format conversion and rendering.
Definition: fs_image.h:47
int GetBpp() const
Get bitmap bits-per-pixel.
Unknown image type.
Definition: fs_image.h:454
Definition: fs_image.h:36
Image type is PNG.
Definition: fs_image.h:466
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.
DIB format: 8bpp alpha mask.
Definition: fs_image.h:57
FX_UINT8 uint8
8-bit unsigned integer.
Definition: fs_basictypes.h:204
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
Header file for file operation related definitions and functions.
File reading interface.
Definition: fx_stream.h:566
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:468
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:472
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.
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:210
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:669
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:214
Header file for common definitions and classes.
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:407
int GetWidth() const
Get image width.
int GetHeight() const
Get bitmap height.
Type
Enumeration for image type.
Definition: fs_image.h:452
const uint8 * GetBuffer() const
Get bitmap buffer.
Foxit namespace.
Definition: fs_taggedpdf.h:27
Image type is TIF or TIFF.
Definition: fs_image.h:470
Bitmap Flip(bool is_flip_horz, bool is_flip_vert)
Flip bitmap.
int GetXDPI() const
Get DPI for X-axis.
Bitmap GetMask(const RectI *clip_rect=0)
Get the mask if bitmap has mask.
int GetPitch() const
Get bitmap pitch.
int GetYDPI() const
Get DPI for Y-axis.
#define NULL
The null-pointer value.
Definition: fx_system.h:780
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:460
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:464
Definition: fs_image.h:445
Image type is BMP.
Definition: fs_image.h:462
bool operator==(const Image &other) const
Equal operator.
Image type is JBIG2.
Definition: fs_image.h:477