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 {
45 e_DIBInvalid = 0,
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
80 } InterpolationFlag;
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
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
429 Bitmap ConvertToMono();
430
431 // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
432 explicit Bitmap(FS_HANDLE handle);
433 };
434
459 class Image FS_FINAL : public Base {
460 public:
466 typedef enum _Type {
468 e_Unknown = -1,
474 e_None = 0,
476 e_BMP = 1,
478 e_JPG = 2,
480 e_PNG = 3,
482 e_GIF = 4,
484 e_TIF = 5,
486 e_JPX = 6,
491 e_JBIG2 = 8,
496 e_WEBP = 9
497 } Type;
498
504 typedef enum _Orientation {
506 e_OrientationNone = 0,
508 e_OrientationNormal = 1,
510 e_OrientationFlipH = 2,
512 e_OrientationRotate180 = 3,
514 e_OrientationFlipV = 4,
516 e_OrientationRotate90FlipH = 5,
518 e_OrientationRotate90 = 6,
520 e_OrientationRotate270FlipH = 7,
522 e_OrientationRotate270 = 8
523 } Orientation;
524
525
532 Image();
533
539 explicit Image(const char* path);
540
546 explicit Image(const wchar_t* path);
547
555 explicit Image(const void* buffer, size_t length);
556
563 explicit Image(foxit::common::file::ReaderCallback* file_read);
564
566 ~Image();
567
573 Image(const Image& other);
574
582 Image& operator = (const Image& other);
583
591 bool IsEmpty() const;
592
600 bool operator == (const Image& other) const;
608 bool operator != (const Image& other) const;
609
618 Type GetType() const;
619
627 int GetWidth() const;
628
636 int GetHeight() const;
637
645 int GetFrameCount() const;
646
664 Bitmap GetFrameBitmap(int index) const;
665
675 int GetXDPI() const;
676
686 int GetYDPI() const;
687
708 bool AddFrame(const Bitmap& bitmap);
709
721 void SetDPIs(int x_dpi, int y_dpi);
722
752 bool SaveAs(const char* file_path);
753
783 bool SaveAs(const wchar_t* file_path);
784
815 bool SaveAs(foxit::common::file::StreamCallback* file, const wchar_t* file_extension);
816
825 Orientation GetOrientation() const;
826
827 // User is strongly recommended NOT to use this method; otherwise unknown situation may occur.
828 explicit Image(FS_HANDLE handle);
829
830 };
831 } // namespace common
832 } // namespace foxit
833 #endif // FS_IMAGE_H_
834
foxit::common::Image::Type
Type
Enumeration for image type.
Definition: fs_image.h:466
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 between bitmaps.
Definition: fs_image.h:47
foxit::common::Image::e_None
Not have image type yet.
Definition: fs_image.h:474
foxit::common::Bitmap::GetFormat
DIBFormat GetFormat() const
Get bitmap format.
foxit::common::Image::e_GIF
Image type is GIF.
Definition: fs_image.h:482
foxit::common::Image::GetOrientation
Orientation GetOrientation() const
Get image orientation.
foxit::FS_HANDLE
void * FS_HANDLE
Handle type.
Definition: fs_basictypes.h:213
foxit::common::Bitmap::GetBuffer
const uint8 * GetBuffer() const
Get bitmap buffer.
foxit::common::Image::Orientation
Orientation
Enumeration for image orientation.
Definition: fs_image.h:504
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:468
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_WEBP
Image type is webp.
Definition: fs_image.h:496
foxit::common::Image::e_JBIG2
Image type is JBIG2.
Definition: fs_image.h:491
IFX_FileStream
File stream interface, reading & writing.
Definition: fx_stream.h:692
fs_common.h
Header file for common definitions and classes.
foxit::common::Image::e_OrientationRotate90FlipH
First rotate 90 in clockwise direction and then flip horizontal.
Definition: fs_image.h:516
foxit::uint8
FX_UINT8 uint8
8-bit unsigned integer.
Definition: fs_basictypes.h:203
IFX_FileRead
File reading interface.
Definition: fx_stream.h:587
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:209
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::Image::e_OrientationRotate270
Rotate 90 degrees in counter-clockwise direction.
Definition: fs_image.h:522
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::Image::e_OrientationRotate270FlipH
First rotate 90 in counter-clockwise direction and then flip horizontal.
Definition: fs_image.h:520
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_OrientationNormal
Normal orientation.
Definition: fs_image.h:508
foxit::common::Image::e_JPX
Image type is JPX or JPEG-2000.
Definition: fs_image.h:486
foxit::common::Bitmap::e_DIBInvalid
Invalid DIB format.
Definition: fs_image.h:45
foxit::common::Bitmap::ConvertToMono
Bitmap ConvertToMono()
Converts bitmap to 1-bit monochrome format.
foxit::common::Image::e_PNG
Image type is PNG.
Definition: fs_image.h:480
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::Image::e_OrientationFlipH
Flip Horizontal.
Definition: fs_image.h:510
foxit::common::Bitmap::e_Downsample
If set, do not do halftone for shrinking or rotating.
Definition: fs_image.h:75
foxit::common::Image::e_OrientationFlipV
Flip Vertical.
Definition: fs_image.h:514
foxit
Foxit namespace.
Definition: fs_taggedpdf.h:27
foxit::common::Image::e_OrientationRotate180
Rotate 180 degrees in clockwise direction.
Definition: fs_image.h:512
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:792
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:484
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:459
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::e_OrientationRotate90
Rotate 90 degrees in clockwise direction.
Definition: fs_image.h:518
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:476
foxit::common::Bitmap::IsEmpty
bool IsEmpty() const
Check whether current object is empty or not.
foxit::Base
Definition: fs_basictypes.h:451
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:478
foxit::common::Image::e_OrientationNone
No orientation.
Definition: fs_image.h:506