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_DIBRgb565 = 0x565
58  } DIBFormat;
59 
65  typedef enum _InterpolationFlag {
67  e_Downsample = 0x01,
69  e_Quadratic = 0x02,
71  e_Bicubic = 0x04
73 
100  Bitmap(int width, int height, DIBFormat format, uint8* buffer = NULL, int pitch = 0);
106  Bitmap(const Bitmap& other);
108  Bitmap();
109 
111  ~Bitmap();
112 
120  Bitmap& operator = (const Bitmap& other);
128  bool operator == (const Bitmap& other) const;
136  bool operator != (const Bitmap& other) const;
137 
145  bool IsEmpty() const;
146 
165  Bitmap Clone(const RectI* clip_rect = NULL) const;
166 
172  int GetWidth() const;
178  int GetHeight() const;
184  int GetPitch() const;
190  int GetBpp() const;
198  const uint8* GetBuffer() const;
205  DIBFormat GetFormat() const;
206 
216  void FillRect(ARGB color, const RectI* rect = NULL);
217 
230  Bitmap& ConvertFormat(DIBFormat format, void* icc_transform = NULL);
231 
244  RectI CalculateBBoxByColor(ARGB backgroud_color);
245 
260  RectI DetectBBoxByColorDiffer(int detection_size, int color_differ = 64);
261 
320  Bitmap SwapXY(bool is_flip_horz, bool is_flip_vert, const RectI* clip_rect = NULL);
321 
339  Bitmap Flip(bool is_flip_horz, bool is_flip_vert);
340 
359  Bitmap StretchTo(int dest_width, int dest_height, InterpolationFlag flag,
360  const RectI* clip_rect = NULL);
361 
384  Bitmap TransformTo(const Matrix& matrix, InterpolationFlag flag,
385  int& out_left, int &out_top, const RectI* clip_rect = NULL);
386 
396  Bitmap GetMask(const RectI* clip_rect = NULL);
397 
398  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
399  explicit Bitmap(FS_HANDLE handle);
400 };
401 
426 class Image FS_FINAL : public Base {
427  public:
433  typedef enum _Type {
435  e_Unknown = -1,
441  e_None = 0,
443  e_BMP = 1,
445  e_JPG = 2,
447  e_PNG = 3,
449  e_GIF = 4,
451  e_TIF = 5,
453  e_JPX = 6,
459  } Type;
460 
461 
468  Image();
469 
475  explicit Image(const char* path);
476 
482  explicit Image(const wchar_t* path);
483 
491  explicit Image(const void* buffer, size_t length);
492 
499  explicit Image(foxit::common::file::ReaderCallback* file_read);
508  explicit Image(std::ifstream* input_file_stream);
509 
511  ~Image();
512 
518  Image(const Image& other);
519 
527  Image& operator = (const Image& other);
528 
536  bool IsEmpty() const;
537 
545  bool operator == (const Image& other) const;
553  bool operator != (const Image& other) const;
554 
563  Type GetType() const;
564 
572  int GetWidth() const;
573 
581  int GetHeight() const;
582 
590  int GetFrameCount() const;
591 
609  Bitmap GetFrameBitmap(int index) const;
610 
620  int GetXDPI() const;
621 
631  int GetYDPI() const;
632 
653  bool AddFrame(const Bitmap& bitmap);
654 
666  void SetDPIs(int x_dpi, int y_dpi);
667 
694  bool SaveAs(const char* file_path);
695 
722  bool SaveAs(const wchar_t* file_path);
723 
751  bool SaveAs(foxit::common::file::StreamCallback* file, const wchar_t* file_extension);
752 
753  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
754  explicit Image(FS_HANDLE handle);
755 };
756 } // namespace common
757 } // namespace foxit
758 #endif // FS_IMAGE_H_
759 
bool operator==(const Bitmap &other) const
Equal operator.
int GetBpp() const
Get bitmap bits-per-pixel.
Unknown image type.
Definition: fs_image.h:435
Definition: fs_image.h:36
Image type is PNG.
Definition: fs_image.h:447
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:51
bool operator!=(const Bitmap &other) const
Not equal operator.
DIB format: 8bpp alpha mask.
Definition: fs_image.h:53
FX_UINT8 uint8
8-bit unsigned integer.
Definition: fs_basictypes.h:206
bool operator!=(const Image &other) const
Not equal operator.
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:47
Header file for file operation related definitions and functions.
file reading interface.
Definition: fx_stream.h:555
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:449
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:453
bool AddFrame(const Bitmap &bitmap)
Add a bitmap as a frame. (Unsupported DIB formats: Bitmap::e_DIBRgb565 and Bitmap::e_DIB8bppMask) ...
16bpp format, bits order: Red 5 bits, Green 6 bits, Blue 5 bits. Red is the lowest order...
Definition: fs_image.h:57
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.
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:212
DIB format: 32bpp format, with bits order "Blue, Green, Red, not used". Blue is in the lowest order...
Definition: fs_image.h:49
File stream interface, reading & writing.
Definition: fx_stream.h:650
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:67
Type GetType() const
Get image type.
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:55
int GetWidth() const
Get bitmap width.
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:216
Header file for common definitions and classes.
int GetFrameCount() const
Get frame count.
Definition: fx_coordinates.h:594
If set, do interpolation for stretching or transforming.
Definition: fs_image.h:69
If set, do bicubic interpolation for stretching or transforming.
Definition: fs_image.h:71
Definition: fs_basictypes.h:342
int GetWidth() const
Get image width.
int GetHeight() const
Get bitmap height.
Type
Enumeration for image type.
Definition: fs_image.h:433
const uint8 * GetBuffer() const
Get bitmap buffer.
Foxit namespace.
Definition: fs_connectedpdf.h:26
Image type is TIF or TIFF.
Definition: fs_image.h:451
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:773
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:441
Definition: fx_coordinates.h:1053
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:65
Image type is JPG or JPeg.
Definition: fs_image.h:445
Definition: fs_image.h:426
Image type is BMP.
Definition: fs_image.h:443
bool operator==(const Image &other) const
Equal operator.
Image type is JBIG2.
Definition: fs_image.h:458

Foxit Software Corporation Logo
@2019 Foxit Software Incorporated. All rights reserved.