64 lines
1.7 KiB
C++
64 lines
1.7 KiB
C++
|
#ifndef IMAGE_PROCESS_H
|
|||
|
#define IMAGE_PROCESS_H
|
|||
|
|
|||
|
#include <stddef.h>
|
|||
|
|
|||
|
typedef unsigned char uchar;
|
|||
|
|
|||
|
class HG_Image
|
|||
|
{
|
|||
|
public:
|
|||
|
enum { AUTO_STEP = 0 };
|
|||
|
|
|||
|
HG_Image();
|
|||
|
|
|||
|
HG_Image(const HG_Image& image);
|
|||
|
|
|||
|
HG_Image(int width, int height, int m_depth, bool isMono = false, size_t step = AUTO_STEP);
|
|||
|
|
|||
|
HG_Image(int width, int height, int m_depth, uchar* data, bool isMono = false, size_t step = AUTO_STEP);
|
|||
|
|
|||
|
~HG_Image();
|
|||
|
|
|||
|
inline int width() const { return m_width; }
|
|||
|
|
|||
|
inline int height() const { return m_height; }
|
|||
|
|
|||
|
inline int depth() const { return m_depth; }
|
|||
|
|
|||
|
inline size_t step() const { return m_step; }
|
|||
|
|
|||
|
inline bool isMono() const { return m_isMono; }
|
|||
|
|
|||
|
inline uchar* data() const { return m_data; }
|
|||
|
|
|||
|
bool empty();
|
|||
|
|
|||
|
void release();
|
|||
|
|
|||
|
HG_Image& operator= (const HG_Image& image);
|
|||
|
|
|||
|
HG_Image autoCrop_desaskew_fillBlank(bool isAutoCrop, bool isDesaskew, bool isFillBlank, int dWidth, int dHeight,
|
|||
|
bool isConvex = true, bool isColorBlank = false, double threshold = 40, int noise = 8, int indent = 5);
|
|||
|
|
|||
|
void adjustColors(int brightness, int contrast, float gamma);
|
|||
|
|
|||
|
enum { HG_INTER_NEAREST = 0, HG_INTER_LINER };
|
|||
|
|
|||
|
HG_Image resize(int dWidth, int dHeight, int interpolation = HG_INTER_NEAREST);
|
|||
|
|
|||
|
HG_Image resize(double fx, double fy, int interpolation = HG_INTER_NEAREST);
|
|||
|
|
|||
|
private:
|
|||
|
int m_width; //像素宽度
|
|||
|
int m_height; //像素高度
|
|||
|
int m_depth; //像素通道
|
|||
|
bool m_isMono; //是否是1位图
|
|||
|
size_t m_step; //每行数据大小
|
|||
|
|
|||
|
uchar* m_data; //内部创建空间的头指针,析构时会释放空间
|
|||
|
bool m_isConstructor; //内存为构造函数创建
|
|||
|
};
|
|||
|
|
|||
|
#endif
|