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 
111  Bitmap(int width, int height, DIBFormat format, uint8* buffer = NULL, int pitch = 0);
117  Bitmap(const Bitmap& other);
119  Bitmap();
120 
122  ~Bitmap();
123 
131  Bitmap& operator = (const Bitmap& other);
139  bool operator == (const Bitmap& other) const;
147  bool operator != (const Bitmap& other) const;
148 
156  bool IsEmpty() const;
157 
176  Bitmap Clone(const RectI* clip_rect = NULL) const;
177 
183  int GetWidth() const;
189  int GetHeight() const;
195  int GetPitch() const;
201  int GetBpp() const;
209  const uint8* GetBuffer() const;
216  DIBFormat GetFormat() const;
217 
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 
420  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
421  explicit Bitmap(FS_HANDLE handle);
422 };
423 
448 class Image FS_FINAL : public Base {
449  public:
455  typedef enum _Type {
457  e_Unknown = -1,
463  e_None = 0,
465  e_BMP = 1,
467  e_JPG = 2,
469  e_PNG = 3,
471  e_GIF = 4,
473  e_TIF = 5,
475  e_JPX = 6,
481  } Type;
482 
483 
490  Image();
491 
497  explicit Image(const char* path);
498 
504  explicit Image(const wchar_t* path);
505 
513  explicit Image(const void* buffer, size_t length);
514 
521  explicit Image(foxit::common::file::ReaderCallback* file_read);
522 
524  ~Image();
525 
531  Image(const Image& other);
532 
540  Image& operator = (const Image& other);
541 
549  bool IsEmpty() const;
550 
558  bool operator == (const Image& other) const;
566  bool operator != (const Image& other) const;
567 
576  Type GetType() const;
577 
585  int GetWidth() const;
586 
594  int GetHeight() const;
595 
603  int GetFrameCount() const;
604 
622  Bitmap GetFrameBitmap(int index) const;
623 
633  int GetXDPI() const;
634 
644  int GetYDPI() const;
645 
666  bool AddFrame(const Bitmap& bitmap);
667 
679  void SetDPIs(int x_dpi, int y_dpi);
680 
707  bool SaveAs(const char* file_path);
708 
735  bool SaveAs(const wchar_t* file_path);
736 
764  bool SaveAs(foxit::common::file::StreamCallback* file, const wchar_t* file_extension);
765 
766  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
767  explicit Image(FS_HANDLE handle);
768 };
769 } // namespace common
770 } // namespace foxit
771 #endif // FS_IMAGE_H_
772 
foxit::common::Image::Type
Type
Enumeration for image type.
Definition: fs_image.h:455
foxit::common::Bitmap::StretchTo
Bitmap StretchTo(int dest_width, int dest_height, InterpolationFlag flag, const RectI *clip_rect=0)
Stretch with different size.
foxit::common::Bitmap::e_DIB1bpp
DIB format: 1bpp format, two color RGB bitmap.It does not support format conversion and rendering.
Definition: fs_image.h:47
foxit::common::Image::e_None
Not have image type yet.
Definition: fs_image.h:463
foxit::common::Bitmap::GetFormat
DIBFormat GetFormat() const
Get bitmap format.
foxit::common::Image::e_GIF
Image type is GIF.
Definition: fs_image.h:471
foxit::FS_HANDLE
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:214
foxit::common::Bitmap::GetBuffer
const uint8 * GetBuffer() const
Get bitmap buffer.
foxit::common::Image::~Image
~Image()
Destructor.
foxit::common::Bitmap::GetWidth
int GetWidth() const
Get bitmap width.
foxit::common::Bitmap::e_DIBArgb
DIB format: 32bpp format, with bits order "Blue, Green, Red, Alpha". Blue is in the lowest order.
Definition: fs_image.h:53
foxit::common::Image::Image
Image()
Constructor.
foxit::common::Image::e_Unknown
Unknown image type.
Definition: fs_image.h:457
foxit::common::Bitmap::e_DIB8bppMask
DIB format: 8bpp alpha mask.
Definition: fs_image.h:57
foxit::common::Image::GetWidth
int GetWidth() const
Get image width.
foxit::common::Bitmap::TransformTo
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.
foxit::common::Image::e_JBIG2
Image type is JBIG2.
Definition: fs_image.h:480
IFX_FileStream
File stream interface, reading & writing.
Definition: fx_stream.h:675
fs_common.h
Header file for common definitions and classes.
foxit::uint8
FX_UINT8 uint8
8-bit unsigned integer.
Definition: fs_basictypes.h:204
IFX_FileRead
File reading interface.
Definition: fx_stream.h:570
fs_file.h
Header file for file operation related definitions and functions.
foxit::common::Bitmap::e_DIBRgb565
16bpp format, bits order: Red 5 bits, Green 6 bits, Blue 5 bits. Red is the lowest order.
Definition: fs_image.h:65
foxit::common::Bitmap::e_DIBRgb
DIB format: 24bpp format, with bits order "Blue, Green, Red". Blue is in the lowest order.
Definition: fs_image.h:49
foxit::ARGB
uint32 ARGB
ARGB color type, 32 bits, ((b) | ((g) << 8) | ((r) << 16)) | ((a) << 24)
Definition: fs_basictypes.h:210
foxit::common::Bitmap::ConvertFormat
Bitmap & ConvertFormat(DIBFormat format, void *icc_transform=0)
Convert a bitmap to another specified DIB format.
foxit::common::Bitmap::CalculateBBoxByColor
RectI CalculateBBoxByColor(ARGB backgroud_color)
Calculate the bounding box according to the given background color.
foxit::common::Image::operator==
bool operator==(const Image &other) const
Equal operator.
foxit::common::Bitmap::e_DIB8bppGray
DIB format: 8bpp format, 256 color GrayScale bitmap.
Definition: fs_image.h:61
foxit::common::Bitmap::e_DIBRgb32
DIB format: 32bpp format, with bits order "Blue, Green, Red, not used". Blue is in the lowest order.
Definition: fs_image.h:51
foxit::common::Bitmap::Clone
Bitmap Clone(const RectI *clip_rect=0) const
Clone current bitmap, with specified clip rectangle.
foxit::common::Image::GetYDPI
int GetYDPI() const
Get DPI for Y-axis.
foxit::common::Image::AddFrame
bool AddFrame(const Bitmap &bitmap)
Add a bitmap as a frame. (Unsupported DIB formats: Bitmap::e_DIBRgb565 and Bitmap::e_DIB8bppMask)
foxit::common::Bitmap::operator==
bool operator==(const Bitmap &other) const
Equal operator.
foxit::common::Bitmap::GetMask
Bitmap GetMask(const RectI *clip_rect=0)
Get the mask if bitmap has mask.
foxit::common::Bitmap::GetBpp
int GetBpp() const
Get bitmap bits-per-pixel.
foxit::common::Bitmap::e_DIBAbgr
DIB format: 32bpp format, with bits order "Red, Green, Blue, Alpha". Red is in the lowest order.
Definition: fs_image.h:63
foxit::common::Bitmap::FillRect
void FillRect(ARGB color, const RectI *rect=0)
Fill current bitmap with a specified color.
foxit::common::Image::e_JPX
Image type is JPX or JPEG-2000.
Definition: fs_image.h:475
foxit::common::Bitmap::e_DIBInvalid
Invalid DIB format.
Definition: fs_image.h:45
foxit::common::Image::e_PNG
Image type is PNG.
Definition: fs_image.h:469
foxit::common::Bitmap::GetPitch
int GetPitch() const
Get bitmap pitch.
foxit::common::Image::GetXDPI
int GetXDPI() const
Get DPI for X-axis.
foxit::common::Bitmap::operator!=
bool operator!=(const Bitmap &other) const
Not equal operator.
foxit::common::Image::operator!=
bool operator!=(const Image &other) const
Not equal operator.
foxit::common::Bitmap::InterpolationFlag
InterpolationFlag
Enumeration for bitmap interpolation flags.
Definition: fs_image.h:73
foxit::common::Bitmap::e_Downsample
If set, do not do halftone for shrinking or rotating.
Definition: fs_image.h:75
foxit
Foxit namespace.
Definition: fs_taggedpdf.h:27
foxit::common::Bitmap::~Bitmap
~Bitmap()
Destructor.
foxit::common::Image::SetDPIs
void SetDPIs(int x_dpi, int y_dpi)
Set DPI for X-axis and Y-axis.
foxit::common::Bitmap::Bitmap
Bitmap()
Constructor, as an empty bitmap object.
foxit::common::Bitmap::e_DIB8bpp
DIB format: 8bpp format, 256 color RGB bitmap.
Definition: fs_image.h:59
foxit::common::Image::operator=
Image & operator=(const Image &other)
Assign operator.
foxit::common::Bitmap::e_Quadratic
If set, do interpolation for stretching or transforming.
Definition: fs_image.h:77
foxit::common::Image::GetFrameBitmap
Bitmap GetFrameBitmap(int index) const
Get a frame bitmap, specified by index.
foxit::common::Bitmap::Flip
Bitmap Flip(bool is_flip_horz, bool is_flip_vert)
Flip bitmap.
foxit::common::Image::GetType
Type GetType() const
Get image type.
foxit::common::Bitmap::e_Bicubic
If set, do bicubic interpolation for stretching or transforming.
Definition: fs_image.h:79
NULL
#define NULL
The null-pointer value.
Definition: fx_system.h:780
foxit::common::Image::GetHeight
int GetHeight() const
Get image height.
foxit::common::Bitmap::DIBFormat
DIBFormat
Enumeration for DIB format.
Definition: fs_image.h:43
foxit::common::Image::e_TIF
Image type is TIF or TIFF.
Definition: fs_image.h:473
foxit::common::Bitmap::SwapXY
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 ...
foxit::common::Image::IsEmpty
bool IsEmpty() const
Check whether current object is empty or not.
foxit::common::Bitmap::operator=
Bitmap & operator=(const Bitmap &other)
Assign operator.
foxit::common::Image
Definition: fs_image.h:448
foxit::common::Bitmap::GetHeight
int GetHeight() const
Get bitmap height.
FX_RECT
Definition: fx_coordinates.h:596
foxit::common::Image::SaveAs
bool SaveAs(const char *file_path)
Save current image as an image file.
CFX_Matrix
Definition: fx_coordinates.h:1076
foxit::common::Image::GetFrameCount
int GetFrameCount() const
Get frame count.
foxit::common::Bitmap
Definition: fs_image.h:36
foxit::common::Bitmap::e_DIBCmyk
DIB format: 32bpp CMYK format, with bits order "Cyan, Magenta, Yellow, Black". Cyan is in the lowest ...
Definition: fs_image.h:55
foxit::common::Image::e_BMP
Image type is BMP.
Definition: fs_image.h:465
foxit::common::Bitmap::IsEmpty
bool IsEmpty() const
Check whether current object is empty or not.
foxit::Base
Definition: fs_basictypes.h:427
foxit::common::Bitmap::DetectBBoxByColorDiffer
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...
foxit::common::Image::e_JPG
Image type is JPG or JPEG.
Definition: fs_image.h:467