Files
CodeRepository/Apps/App_GeneralDataInjectionApp/Common/GdImageLib.h

223 lines
8.9 KiB
C
Raw Normal View History

#ifndef __GdImageLib_H__
#define __GdImageLib_H__
#include <memory.h>
#include <QMutex>
#include <QVector>
#include <QRgb>
#include <QImage>
#ifdef __cplusplus
extern "C" {
#endif
#include "./include/ffmpeg4.0/libavcodec/avcodec.h"
#include "./include/ffmpeg4.0/libswscale/swscale.h"
#ifdef __cplusplus
}
#endif
extern unsigned char IRImage_ColorTable[9][256][4];
static class GdImageLib
{
private:
GdImageLib();
public:
/************************************************************************
**
** Y16数据映射成Y8数据
**
** psh16BitData Y16数据
** nDataLen
** nBrightness
** nContrast
**
** pby8BitData Y8数据
**
**
**
************************************************************************/
static void Map16BitTo8Bit_u(unsigned char* pby8BitData, unsigned short *psh16BitData, int nDataLen, int nBrightness = 100, int nContrast = 100);
/************************************************************************
**
** Y16数据映射成Y8数据
**
** psh16BitData Y16数据
** nDataLen
** nBrightness
** nContrast
**
** pby8BitData Y8数据
**
**
**
************************************************************************/
static void Map16BitTo8Bit(unsigned char* pby8BitData, short* psh16BitData, int nDataLen, int nBrightness = 100, int nContrast = 100);
/************************************************************************
**
** RGBA数据
**
** pGrey8 Y16数据
** nImageWidth
** nImageHeight
** nColorTableIndex
**
** pRGBA RGBA数据
**
**
**
************************************************************************/
static bool Grey8ToRGBA(unsigned char *pRGBA, unsigned char *pGrey8, int nImageWidth, int nImageHeight, int nColorTableIndex = 0);
/************************************************************************
**
**
**
** pImgData
** nWidth
** nHeight
** nBytesOfPixel
**
** pImgData
**
**
**
************************************************************************/
static void Flip(unsigned char *pImgData, int nWidth, int nHeight, int nBytesOfPixel);
/************************************************************************
**
**
**
** pImgData
** nWidth
** nHeight
** nBytesOfPixel
**
** pImgData
**
**
**
************************************************************************/
static void Mirror(unsigned char *pImgData, int nWidth, int nHeight, int nBytesOfPixel);
/************************************************************************
**
**
**
** pImgData
** nWidth
** nHeight
** nBytesOfPixel
**
** pImgData
**
**
**
************************************************************************/
static void FlipAndMirror(unsigned char *pImgData, int nWidth, int nHeight, int nBytesOfPixel);
/************************************************************************
**
** 90
**
** pImageData_Src
** nImageWidth_Src
** nImageHeight_Src
** nBytesOfPixel
**
** pImageData_Dest
** nImageWidth_Dest
** nImageHeight_Dest
**
**
**
************************************************************************/
static void Rorate90(unsigned char* pImageData_Dest, int& nImageWidth_Dest, int& nImageHeight_Dest, unsigned char* pImageData_Src, int nImageWidth_Src, int nImageHeight_Src, int nBytesOfPixel);
/************************************************************************
**
** 180
**
** pImageData_Src
** nImageWidth_Src
** nImageHeight_Src
** nBytesOfPixel
**
** pImageData_Dest
** nImageWidth_Dest
** nImageHeight_Dest
**
**
**
************************************************************************/
static void Rorate180(unsigned char* pImageData_Dest, int& nImageWidth_Dest, int& nImageHeight_Dest, unsigned char* pImageData_Src, int nImageWidth_Src, int nImageHeight_Src, int nBytesOfPixel);
/************************************************************************
**
** 270
**
** pImageData_Src
** nImageWidth_Src
** nImageHeight_Src
** nBytesOfPixel
**
** pImageData_Dest
** nImageWidth_Dest
** nImageHeight_Dest
**
**
**
************************************************************************/
static void Rorate270(unsigned char* pImageData_Dest, int& nImageWidth_Dest, int& nImageHeight_Dest, unsigned char* pImageData_Src, int nImageWidth_Src, int nImageHeight_Src, int nBytesOfPixel);
static bool ffmpeg_init();
static void ffmpeg_uninit();
/************************************************************************
**
** 180
**
** pImageData_Src
** srcFmt
** nImageWidth_Src
** nImageHeight_Src
**
** pImageData_Dest
** dstFmt
** nImageWidth_Dest
** nImageHeight_Dest
**
**
**
************************************************************************/
static bool Convert(unsigned char* pImageData_Dest, AVPixelFormat dstFmt, int nImageWidth_Dest, int nImageHeight_Dest, unsigned char* pImageData_Src, AVPixelFormat srcFmt, int nImageWidth_Src, int nImageHeight_Src);
private:
static int m_nImageWidth_Src;
static int m_nImageHeight_Src;
static int m_nImageWidth_Dest;
static int m_nImageHeight_Dest;
static int m_nLineSize_Src[8];
static int m_nLineSize_Dest[8];
static unsigned char* m_pImageData_Src;
static unsigned char* m_pImageData_Dest;
static unsigned char* m_lineData_Src[8];
static unsigned char* m_lineData_Dest[8];
static AVPixelFormat m_pPixelFmt_Src;
static AVPixelFormat m_pPixelFmt_Dest;
static SwsContext* m_pConvert;
static bool m_bUpdate;
static QMutex m_mutexConvert;
//
static QVector<QVector<QRgb> > m_varColorTable;
static bool m_bInitColorTable;
};
#endif // __GdImageLib_H__