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_DIBRgb = 0x018,
49  e_DIBRgb32 = 0x020,
51  e_DIBArgb = 0x220,
53  e_DIB8bppMask = 0x108,
55  e_DIB8bpp = 0x008,
57  e_DIB8bppGray = 0x1008,
59  e_DIBAbgr = 0x222,
61  e_DIBRgb565 = 0x565
62  } DIBFormat;
63 
69  typedef enum _InterpolationFlag {
71  e_Downsample = 0x01,
73  e_Quadratic = 0x02,
75  e_Bicubic = 0x04
77 
104  Bitmap(int width, int height, DIBFormat format, uint8* buffer = NULL, int pitch = 0);
110  Bitmap(const Bitmap& other);
112  Bitmap();
113 
115  ~Bitmap();
116 
124  Bitmap& operator = (const Bitmap& other);
132  bool operator == (const Bitmap& other) const;
140  bool operator != (const Bitmap& other) const;
141 
149  bool IsEmpty() const;
150 
169  Bitmap Clone(const RectI* clip_rect = NULL) const;
170 
176  int GetWidth() const;
182  int GetHeight() const;
188  int GetPitch() const;
194  int GetBpp() const;
202  const uint8* GetBuffer() const;
209  DIBFormat GetFormat() const;
210 
220  void FillRect(ARGB color, const RectI* rect = NULL);
221 
234  Bitmap& ConvertFormat(DIBFormat format, void* icc_transform = NULL);
235 
248  RectI CalculateBBoxByColor(ARGB backgroud_color);
249 
264  RectI DetectBBoxByColorDiffer(int detection_size, int color_differ = 64);
265 
324  Bitmap SwapXY(bool is_flip_horz, bool is_flip_vert, const RectI* clip_rect = NULL);
325 
343  Bitmap Flip(bool is_flip_horz, bool is_flip_vert);
344 
363  Bitmap StretchTo(int dest_width, int dest_height, InterpolationFlag flag,
364  const RectI* clip_rect = NULL);
365 
388  Bitmap TransformTo(const Matrix& matrix, InterpolationFlag flag,
389  int& out_left, int &out_top, const RectI* clip_rect = NULL);
390 
400  Bitmap GetMask(const RectI* clip_rect = NULL);
401 
402  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
403  explicit Bitmap(FS_HANDLE handle);
404 };
405 
430 class Image FS_FINAL : public Base {
431  public:
437  typedef enum _Type {
439  e_Unknown = -1,
445  e_None = 0,
447  e_BMP = 1,
449  e_JPG = 2,
451  e_PNG = 3,
453  e_GIF = 4,
455  e_TIF = 5,
457  e_JPX = 6,
463  } Type;
464 
465 
472  Image();
473 
479  explicit Image(const char* path);
480 
486  explicit Image(const wchar_t* path);
487 
495  explicit Image(const void* buffer, size_t length);
496 
503  explicit Image(foxit::common::file::ReaderCallback* file_read);
504 
506  ~Image();
507 
513  Image(const Image& other);
514 
522  Image& operator = (const Image& other);
523 
531  bool IsEmpty() const;
532 
540  bool operator == (const Image& other) const;
548  bool operator != (const Image& other) const;
549 
558  Type GetType() const;
559 
567  int GetWidth() const;
568 
576  int GetHeight() const;
577 
585  int GetFrameCount() const;
586 
604  Bitmap GetFrameBitmap(int index) const;
605 
615  int GetXDPI() const;
616 
626  int GetYDPI() const;
627 
648  bool AddFrame(const Bitmap& bitmap);
649 
661  void SetDPIs(int x_dpi, int y_dpi);
662 
689  bool SaveAs(const char* file_path);
690 
717  bool SaveAs(const wchar_t* file_path);
718 
746  bool SaveAs(foxit::common::file::StreamCallback* file, const wchar_t* file_extension);
747 
748  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
749  explicit Image(FS_HANDLE handle);
750 };
751 } // namespace common
752 } // namespace foxit
753 #endif // FS_IMAGE_H_
754 
Type
Enumeration for image type.
Definition: fs_image.h:437
Bitmap StretchTo(int dest_width, int dest_height, InterpolationFlag flag, const RectI *clip_rect=0)
Stretch with different size.
Not have image type yet.
Definition: fs_image.h:445
DIBFormat GetFormat() const
Get bitmap format.
Image type is GIF.
Definition: fs_image.h:453
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:216
const uint8 * GetBuffer() const
Get bitmap buffer.
~Image()
Destructor.
int GetWidth() const
Get bitmap width.
DIB format: 32bpp format, with bits order "Blue, Green, Red, Alpha". Blue is in the lowest order.
Definition: fs_image.h:51
Image()
Constructor.
Unknown image type.
Definition: fs_image.h:439
DIB format: 8bpp alpha mask.
Definition: fs_image.h:53
int GetWidth() const
Get image width.
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.
Image type is JBIG2.
Definition: fs_image.h:462
File stream interface, reading & writing.
Definition: fx_stream.h:669
Header file for common definitions and classes.
FX_UINT8 uint8
8-bit unsigned integer.
Definition: fs_basictypes.h:206
File reading interface.
Definition: fx_stream.h:566
Header file for file operation related definitions and functions.
16bpp format, bits order: Red 5 bits, Green 6 bits, Blue 5 bits. Red is the lowest order.
Definition: fs_image.h:61
DIB format: 24bpp format, with bits order "Blue, Green, Red". Blue is in the lowest order.
Definition: fs_image.h:47
uint32 ARGB
ARGB color type, 32 bits, ((b) | ((g) << 8) | ((r) << 16)) | ((a) << 24)
Definition: fs_basictypes.h:212
Bitmap & ConvertFormat(DIBFormat format, void *icc_transform=0)
Convert a bitmap to another specified DIB format.
RectI CalculateBBoxByColor(ARGB backgroud_color)
Calculate the bounding box according to the given background color.
bool operator==(const Image &other) const
Equal operator.
DIB format: 8bpp format, 256 color GrayScale bitmap.
Definition: fs_image.h:57
bool operator !=(const Image &other) const
Not equal operator.
DIB format: 32bpp format, with bits order "Blue, Green, Red, not used". Blue is in the lowest order.
Definition: fs_image.h:49
Bitmap Clone(const RectI *clip_rect=0) const
Clone current bitmap, with specified clip rectangle.
int GetYDPI() const
Get DPI for Y-axis.
bool AddFrame(const Bitmap &bitmap)
Add a bitmap as a frame. (Unsupported DIB formats: Bitmap::e_DIBRgb565 and Bitmap::e_DIB8bppMask)
bool operator==(const Bitmap &other) const
Equal operator.
Bitmap GetMask(const RectI *clip_rect=0)
Get the mask if bitmap has mask.
int GetBpp() const
Get bitmap bits-per-pixel.
DIB format: 32bpp format, with bits order "Red, Green, Blue, Alpha". Red is in the lowest order.
Definition: fs_image.h:59
void FillRect(ARGB color, const RectI *rect=0)
Fill current bitmap with a specified color.
Image type is JPX or JPeg-2000.
Definition: fs_image.h:457
Invalid DIB format.
Definition: fs_image.h:45
Image type is PNG.
Definition: fs_image.h:451
int GetPitch() const
Get bitmap pitch.
int GetXDPI() const
Get DPI for X-axis.
InterpolationFlag
Enumeration for bitmap interpolation flags.
Definition: fs_image.h:69
If set, do not do halftone for shrinking or rotating.
Definition: fs_image.h:71
Foxit namespace.
Definition: fs_compare.h:27
~Bitmap()
Destructor.
void SetDPIs(int x_dpi, int y_dpi)
Set DPI for X-axis and Y-axis.
Bitmap()
Constructor, as an empty bitmap object.
DIB format: 8bpp format, 256 color RGB bitmap.
Definition: fs_image.h:55
Image & operator=(const Image &other)
Assign operator.
If set, do interpolation for stretching or transforming.
Definition: fs_image.h:73
Bitmap GetFrameBitmap(int index) const
Get a frame bitmap, specified by index.
Bitmap Flip(bool is_flip_horz, bool is_flip_vert)
Flip bitmap.
Type GetType() const
Get image type.
If set, do bicubic interpolation for stretching or transforming.
Definition: fs_image.h:75
#define NULL
The null-pointer value.
Definition: fx_system.h:767
int GetHeight() const
Get image height.
DIBFormat
Enumeration for DIB format.
Definition: fs_image.h:43
Image type is TIF or TIFF.
Definition: fs_image.h:455
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 ...
bool IsEmpty() const
Check whether current object is empty or not.
Bitmap & operator=(const Bitmap &other)
Assign operator.
Definition: fs_image.h:430
int GetHeight() const
Get bitmap height.
Definition: fx_coordinates.h:596
bool SaveAs(const char *file_path)
Save current image as an image file.
Definition: fx_coordinates.h:1076
int GetFrameCount() const
Get frame count.
Definition: fs_image.h:36
Image type is BMP.
Definition: fs_image.h:447
bool IsEmpty() const
Check whether current object is empty or not.
Definition: fs_basictypes.h:399
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...
Image type is JPG or JPeg.
Definition: fs_image.h:449
bool operator !=(const Bitmap &other) const
Not equal operator.