Foxit PDF SDK
fs_image.h
浏览该文件的文档.
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 
337  Bitmap SwapXY(bool is_flip_horz, bool is_flip_vert, const RectI* clip_rect = NULL);
338 
356  Bitmap Flip(bool is_flip_horz, bool is_flip_vert);
357 
377  Bitmap StretchTo(int dest_width, int dest_height, InterpolationFlag flag,
378  const RectI* clip_rect = NULL);
379 
401  Bitmap TransformTo(const Matrix& matrix, InterpolationFlag flag,
402  int& out_left, int &out_top, const RectI* clip_rect = NULL);
403 
413  Bitmap GetMask(const RectI* clip_rect = NULL);
414 
425 
426  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
427  explicit Bitmap(FS_HANDLE handle);
428 };
429 
449 class Image FS_FINAL : public Base {
450  public:
456  typedef enum _Type {
458  e_Unknown = -1,
464  e_None = 0,
466  e_BMP = 1,
468  e_JPG = 2,
470  e_PNG = 3,
472  e_GIF = 4,
474  e_TIF = 5,
476  e_JPX = 6,
481  e_JBIG2 = 8,
486  e_WEBP = 9
487  } Type;
488 
494  typedef enum _Orientation {
513  } Orientation;
514 
515 
522  Image();
523 
529  explicit Image(const char* path);
530 
536  explicit Image(const wchar_t* path);
537 
545  explicit Image(const void* buffer, size_t length);
546 
553  explicit Image(foxit::common::file::ReaderCallback* file_read);
554 
556  ~Image();
557 
563  Image(const Image& other);
564 
572  Image& operator = (const Image& other);
573 
581  bool IsEmpty() const;
582 
590  bool operator == (const Image& other) const;
598  bool operator != (const Image& other) const;
599 
608  Type GetType() const;
609 
617  int GetWidth() const;
618 
626  int GetHeight() const;
627 
635  int GetFrameCount() const;
636 
654  Bitmap GetFrameBitmap(int index) const;
655 
665  int GetXDPI() const;
666 
676  int GetYDPI() const;
677 
698  bool AddFrame(const Bitmap& bitmap);
699 
711  void SetDPIs(int x_dpi, int y_dpi);
712 
742  bool SaveAs(const char* file_path);
743 
773  bool SaveAs(const wchar_t* file_path);
774 
805  bool SaveAs(foxit::common::file::StreamCallback* file, const wchar_t* file_extension);
806 
815  Orientation GetOrientation() const;
816 
817  // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
818  explicit Image(FS_HANDLE handle);
819 
820 };
821 } // namespace common
822 } // namespace foxit
823 #endif // FS_IMAGE_H_
824 
bool operator==(const Bitmap &other) const
相等操作符。
无方向。
Definition: fs_image.h:496
DIB 格式:32bpp CMYK 格式,位顺序为"青、品红、黄、黑"。青色在最低位。
Definition: fs_image.h:55
Bitmap ConvertToMono()
将位图转换为1位单色格式。
DIB 格式:1bpp 格式,双色 RGB 位图。不支持位图之间的格式转换。
Definition: fs_image.h:47
int GetBpp() const
获取位图每像素位数。
未知图像类型。
Definition: fs_image.h:458
Orientation GetOrientation() const
获取图像方向。
Definition: fs_image.h:36
图像类型是PNG。
Definition: fs_image.h:470
Bitmap GetFrameBitmap(int index) const
根据索引获取帧位图。
bool IsEmpty() const
检查当前对象是否为空。
Image()
构造函数。
DIB 格式:32bpp 格式,位顺序为"蓝、绿、红、Alpha"。蓝色在最低位。
Definition: fs_image.h:53
bool operator !=(const Bitmap &other) const
不相等操作符。
先顺时针旋转90度,然后水平翻转。
Definition: fs_image.h:506
DIB格式:8bpp Alpha遮罩。
Definition: fs_image.h:57
FX_UINT8 uint8
无符号 8 位整数。
Definition: fs_basictypes.h:204
Bitmap & operator=(const Bitmap &other)
赋值操作符。
DIB 格式:24bpp 格式,位顺序为"蓝、绿、红"。蓝色在最低位。
Definition: fs_image.h:49
先逆时针旋转90度,然后水平翻转。
Definition: fs_image.h:510
文件操作相关定义和函数的头文件。
文件读取接口。
Definition: fx_stream.h:587
DIBFormat
DIB 格式的枚举。
Definition: fs_image.h:43
Bitmap & ConvertFormat(DIBFormat format, void *icc_transform=0)
将位图转换为另一种指定的DIB格式。
Bitmap TransformTo(const Matrix &matrix, InterpolationFlag flag, int &out_left, int &out_top, const RectI *clip_rect=0)
将当前位图(作为源位图)转换到目标位图。
int GetHeight() const
获取图像高度。
图像类型是GIF。
Definition: fs_image.h:472
Bitmap Clone(const RectI *clip_rect=0) const
克隆当前位图,使用指定的裁剪矩形。
~Image()
析构函数。
DIBFormat GetFormat() const
获取位图格式。
图像类型是JPX或JPEG-2000。
Definition: fs_image.h:476
图像类型是webp。
Definition: fs_image.h:486
bool AddFrame(const Bitmap &bitmap)
添加位图作为帧。(不支持的DIB格式:Bitmap::e_DIBRgb565 和 Bitmap::e_DIB8bppMask)
DIB格式:8bpp格式,256色灰度位图。
Definition: fs_image.h:61
16bpp格式,位顺序:红色5位,绿色6位,蓝色5位。红色在最低位。
Definition: fs_image.h:65
Bitmap StretchTo(int dest_width, int dest_height, InterpolationFlag flag, const RectI *clip_rect=0)
按不同大小拉伸。
bool SaveAs(const char *file_path)
将当前图像保存为图像文件。
Bitmap()
构造函数,作为空位图对象。
Image & operator=(const Image &other)
赋值操作符。
DIB格式:32bpp格式,位顺序为"红、绿、蓝、Alpha"。红色在最低位。
Definition: fs_image.h:63
RectI CalculateBBoxByColor(ARGB backgroud_color)
根据给定的背景色计算边界框。
逆时针旋转90度。
Definition: fs_image.h:512
顺时针旋转90度。
Definition: fs_image.h:508
Bitmap SwapXY(bool is_flip_horz, bool is_flip_vert, const RectI *clip_rect=0)
交换位图的X、Y坐标。交换后,图像还可以同时翻转。
uint32 ARGB
ARGB 颜色类型,32 位,((b) | ((g) << 8) | ((r) << 16)) | ((a) << 24)
Definition: fs_basictypes.h:210
顺时针旋转180度。
Definition: fs_image.h:502
DIB 格式:32bpp 格式,位顺序为"蓝、绿、红、未使用"。蓝色在最低位。
Definition: fs_image.h:51
文件流接口,用于读取和写入。
Definition: fx_stream.h:692
正常方向。
Definition: fs_image.h:498
void FillRect(ARGB color, const RectI *rect=0)
用指定颜色填充当前位图。
无效的 DIB 格式。
Definition: fs_image.h:45
如果设置,对于缩小或旋转不进行半色调处理。
Definition: fs_image.h:75
Type GetType() const
获取图像类型。
bool operator !=(const Image &other) const
不等操作符。
bool IsEmpty() const
检查当前对象是否为空。
~Bitmap()
析构函数。
DIB格式:8bpp格式,256色RGB位图。
Definition: fs_image.h:59
int GetWidth() const
获取位图宽度。
void * FS_HANDLE
句柄类型。
Definition: fs_basictypes.h:214
通用定义和类的头文件。
垂直翻转。
Definition: fs_image.h:504
int GetFrameCount() const
获取帧数。
Definition: fx_coordinates.h:596
如果设置,对于拉伸或变换进行插值处理。
Definition: fs_image.h:77
如果设置,对于拉伸或变换进行双三次插值处理。
Definition: fs_image.h:79
Definition: fs_basictypes.h:449
int GetWidth() const
获取图像宽度。
int GetHeight() const
获取位图高度。
Type
图像类型的枚举。
Definition: fs_image.h:456
const uint8 * GetBuffer() const
获取位图缓冲区。
Foxit命名空间。
Definition: fs_taggedpdf.h:27
图像类型是TIF或TIFF。
Definition: fs_image.h:474
Bitmap Flip(bool is_flip_horz, bool is_flip_vert)
翻转位图。
int GetXDPI() const
获取X轴的DPI。
Orientation
图像方向的枚举。
Definition: fs_image.h:494
Bitmap GetMask(const RectI *clip_rect=0)
如果位图有遮罩则获取该遮罩。
水平翻转。
Definition: fs_image.h:500
int GetPitch() const
获取位图间距。
int GetYDPI() const
获取Y轴的DPI。
#define NULL
空指针值。
Definition: fx_system.h:792
RectI DetectBBoxByColorDiffer(int detection_size, int color_differ=64)
根据内容与边距之间的给定颜色差异检测内容的边界框。
尚未有图像类型。
Definition: fs_image.h:464
Definition: fx_coordinates.h:1076
void SetDPIs(int x_dpi, int y_dpi)
设置X轴和Y轴的DPI。
InterpolationFlag
位图插值标志的枚举。
Definition: fs_image.h:73
图像类型是JPG或JPEG。
Definition: fs_image.h:468
Definition: fs_image.h:449
图像类型是BMP。
Definition: fs_image.h:466
bool operator==(const Image &other) const
相等操作符。
图像类型是JBIG2。
Definition: fs_image.h:481