#ifndef LCF_IMG_HANDLE_H_
#define LCF_IMG_HANDLE_H_

#define NORM_FACTOR 0.00392F /* 1/255 = 0.00392 */
#define NEED_CHANNELS 3

class ImgHandle {
    public:
        static void GetImgHWCByBuff(unsigned char *fBuff, int fLen, int *h, int *w, int *c);
        static unsigned char *LoadBGRCHWUcImg(const char *fName, int *c, int *h, int *w);
        static unsigned char *LoadBGRCHWUcImg(unsigned char *fBuff, int len, int *c, int *h, int *w);
        static float *LoadBGRCHWFloatImg(const char *fName, int ifNorm, int *c, int *h, int *w);
        static float *LoadBGRCHWFloatImg(unsigned char *fBuff, int fLen, int ifNorm, int *c, int *h, int *w);
        static void RGB_BGR_Exchange(unsigned char *rgbMat, int h, int w, int c);
        static unsigned char *CHWConvertTOHWC(unsigned char *chwMat, int channels, int height, int width);
        static unsigned char *HWCConvertTOCHW(unsigned char *hwcMat, int height, int width, int channels);
        static unsigned char *LoadImageToZoomSquareMatOfHW(unsigned char *fBuff, int fLen, int hwLen);
        static unsigned char *LoadImageToZoomSquareMatOfHW(const char *fName, int hwLen);
        static float *UCharArrayToFloatArray(unsigned char *ucMatrix, int len);
        static unsigned char *FloatArrayToUCharArray(float *fMatrix, int len);
        static unsigned char *LoadImageToSquareMatByMaxHW(const char *fName, int *hw);
        static float DoubleLinearInterpolation(float x, float y, float f00, float f01, float f10, float f11);
        static unsigned char *GetZoomImgFromSrcImg(unsigned char *srcMat, int chn, int h, int w, int distImgH, int distImgW);
        static unsigned char *LoadImageToGaryMat(const char *fName, int *oH, int *oW);
        static unsigned char *ColorMatToGaryMat(unsigned char *mat, int c, int h, int w);
        static float *LoadSquareImg(unsigned char *fBuff, int fLen, int ifNorm, int *c, int *h, int *w, int hwLen);
        static float *LoadSquareImg(const char *fName, int ifNorm, int *c, int *h, int *w, int hwLen);
        static float *UCToFloatByFactor(unsigned char *srcPic, int len,  float factor);
        static void CHW_BGR_MatSaveToImg(float *chwRGBMat, int c, int h, int w, int ifNormed, const char* fName);
        static void CHWMatDrawBox(float *mat, int channels, int row, int col, int x1, int y1, int x2, int y2, int b, int g, int r);
        static void CHWMatDrawBox(float *mat, int ch, int row, int col, float cx, float cy, float w, float h, int b, int g, int r);
        static void CHW_BGR_MatSaveToImg(unsigned char *chwRGBMat, int c, int h, int w, const char *fName);
        static float *GetZoomImgFromSrcImgFloat(float *srcMat, int inBatNum, int c, int h, int w, int distImgH, int distImgW);
};

#endif
