代码拉取完成,页面将自动刷新
同步操作将从 ZVision/UVCCapture 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
* Copyright (c) 2020-2022 https://gitee.com/fsfzp888/UVCCapture
* All rights reserved
*/
#ifndef IMAGE_FORMATS_H
#define IMAGE_FORMATS_H
#include <dshow.h>
#include <QImage>
#include <functional>
#include <string>
/**
* @brief Interface for a function that makes QImage from raw data
*
* @param data
* @param len
* @param width
* @param height
* @return QImage
*/
typedef std::function<QImage(const unsigned char *data, unsigned len, unsigned width, unsigned height)> QImageMaker;
/**
* @brief Description for image format table's row
*
* @param name
* @param directshowFormat
* @param makeQImage
*/
struct ImageFormatRow
{
/**
* @brief Frendly format name
*/
std::string name;
/**
* @brief DirectShow format GUID
*/
GUID directshowFormat;
/**
* @brief Function that makes QImage from raw data
*/
QImageMaker makeQImage;
};
/**
* @brief Make QImage from ARGB32 frame
*
* @param data
* @param len
* @param width
* @param height
* @return QImage
*/
QImage makeARGB32Image(const unsigned char *data, unsigned len, unsigned width, unsigned height);
/**
* @brief Make QImage from RGB32 frame
*
* @param data
* @param len
* @param width
* @param height
* @return QImage
*/
QImage makeRGB32Image(const unsigned char *data, unsigned len, unsigned width, unsigned height);
/**
* @brief Make QImage from RGB24 frame
*
* @param data
* @param len
* @param width
* @param height
* @return QImage
*/
QImage makeRGB24Image(const unsigned char *data, unsigned len, unsigned width, unsigned height);
/**
* @brief Make QImage from RGB555 frame
*
* @param data
* @param len
* @param width
* @param height
* @return QImage
*/
QImage makeRGB555Image(const unsigned char *data, unsigned len, unsigned width, unsigned height);
/**
* @brief Make QImage from RGB565 frame
*
* @param data
* @param len
* @param width
* @param height
* @return QImage
*/
QImage makeRGB565Image(const unsigned char *data, unsigned len, unsigned width, unsigned height);
/**
* @brief Make QImage from JPEG frame
*
* @param data
* @param len
* @param width
* @param height
* @return QImage
*/
QImage makeJPGImage(const unsigned char *data, unsigned len, unsigned width, unsigned height);
/**
* @brief Make QImage from YUY2 frame
*
* @param data
* @param len
* @param width
* @param height
* @return QImage
*/
QImage makeYUY2Image(const unsigned char *data, unsigned len, unsigned width, unsigned height);
/**
* @brief A dummy function which returns empty QImage
*
* @param data
* @param len
* @param width
* @param height
* @return QImage
*/
QImage dummy(const unsigned char *data, unsigned len, unsigned width, unsigned height);
/**
* @brief Convert YUV to JPEG
*/
//unsigned long YUV2ToJPG(int width, int height, const unsigned char* inputYuv, unsigned char** outJpeg);
void ConvertToJPEGBuf(const QImage& img, QByteArray& ba);
/**
* @brief Image format table
*/
static ImageFormatRow ImageFormatTable[] = {{"ARGB32", MEDIASUBTYPE_ARGB32, makeARGB32Image},
{"RGB32", MEDIASUBTYPE_RGB32, makeRGB32Image},
{"RGB24", MEDIASUBTYPE_RGB24, makeRGB24Image},
{"RGB555", MEDIASUBTYPE_RGB555, makeRGB555Image},
{"RGB565", MEDIASUBTYPE_RGB565, makeRGB565Image},
{"MJPG", MEDIASUBTYPE_MJPG, makeJPGImage},
{"JPG", MEDIASUBTYPE_IJPG, makeJPGImage},
{"AYUV", MEDIASUBTYPE_AYUV, dummy},
{"IYUV", MEDIASUBTYPE_IYUV, dummy},
{"YV12", MEDIASUBTYPE_YV12, dummy},
{"UYVY", MEDIASUBTYPE_UYVY, dummy},
{"YUYV", MEDIASUBTYPE_YUYV, dummy},
{"YUY2", MEDIASUBTYPE_YUY2, makeYUY2Image},
{"NV12", MEDIASUBTYPE_NV12, dummy},
{"IMC1", MEDIASUBTYPE_IMC1, dummy},
{"IMC2", MEDIASUBTYPE_IMC2, dummy},
{"IMC3", MEDIASUBTYPE_IMC3, dummy},
{"IMC4", MEDIASUBTYPE_IMC4, dummy}};
const std::string &getImageFormatName(const GUID &uid);
QImageMaker getQImageMaker(const GUID &uid);
bool isKnownImageFormat(const GUID &uid);
inline bool isJPEGFormat(const GUID& uid)
{
return uid == MEDIASUBTYPE_MJPG || uid == MEDIASUBTYPE_IJPG;
}
#endif // IMAGE_FORMATS_H
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。