Files
CodeRepository/Common/GdImageLib.h
chenzhen 222dda1e43 1,新增“App_ThermalImageSystem”;
2,新增“Apps”;
3,新增“Common”;
4,新增“FileList”;
5,新增“MediaX”;
6,新增“OpenSource”;
7,新增“Samples”;
8,新增“SoftwareBusinessLines”.
2026-02-14 23:03:23 +08:00

223 lines
8.9 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#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__