⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 videomaninputformat.cpp

📁 VideoMan is a very easy image acquisition library. It is able to manage many video inputs at the sam
💻 CPP
字号:
#include "VideoManInputFormat.h"

VideoManInputFormat::VideoManInputFormat(void)
{
	SetFormat( 320, 240, 60, UNKNOWN, RGB24 );	
	showDlg = false;
	dropFrames = true;
	clock = true;
	renderAudio = true;	
	timeFormat = FRAMES;
}


VideoManInputFormat::~VideoManInputFormat(void)
{
}

VideoManInputFormat::VideoManInputFormat(VideoManInputFormat const &format)
{
	*this = format;
}

VideoManInputFormat &VideoManInputFormat::operator=( VideoManInputFormat const &format )
{
	this->nChannels = format.nChannels;
	this->depth = format.depth;
	this->width = format.width;
	this->height = format.height;
	this->fps = format.fps;
	this->showDlg = format.showDlg;
	this->dropFrames = format.dropFrames;
	this->clock = format.clock;
	this->renderAudio = format.renderAudio;
	this->timeFormat = format.timeFormat;
	this->pixelFormats = format.pixelFormats;
	return *this;	
}


bool VideoManInputFormat::SetFormat( int awidth, int aheight, double afps, PIXEL_FORMAT apixelFormatIn, PIXEL_FORMAT apixelFormatOut )
{
	width = awidth;
	height = aheight;
	fps = afps;		
	if ( !setPixelFormat( apixelFormatIn, apixelFormatOut ) )
		return false;
	if ( !validFormat() )
		return false;
	return true;
}

bool VideoManInputFormat::setPixelFormat( PIXEL_FORMAT apixelFormatIn, PIXEL_FORMAT apixelFormatOut )
{
	pixelFormats.formatIn = apixelFormatIn;
	pixelFormats.formatOut = apixelFormatOut;
	switch ( apixelFormatOut )
	{
		case RGB24:
		case BGR24:
		{
			depth = 8;
			nChannels = 3;
			break;
		}
		case RGB32:
		case BGR32:
		{
			depth = 8;
			nChannels = 4;		
			break;
		}
		case GREY16:
		{
			depth = 16;
			nChannels = 1;
			break;
		}
		case GREY8:
		{
			depth = 8;
			nChannels = 1;
			break;
		}
		case RAW8:
		{
			depth = 8;
			nChannels = 1;
			break;
		}
		case YUV422:
		{
			depth = 16;
			nChannels = 3;
			break;
		}
	}
	/*BppCalc = calculateBpp( pixelFormats.formatOut );
	if ( BppCalc == -1 )
		return false;
	else
		BppOut = BppCalc;*/
	return true;
}

/*float VideoManInputFormat::calculateBpp( PIXEL_FORMAT apixelFormat )
{
	float BPPret = -1;
	switch ( apixelFormat )
	{
		case RGB24:
		case BGR24:
		{
			BPPret = 3;
			break;
		}
		case RGB32:
		case BGR32:
		{
			BPPret = 4;				
			break;
		}
		case GREY16:
		{
			BPPret = 2;                
			break;
		}
		case GREY8:
		{
			BPPret = 1;				
			break;
		}
		case RAW8:
		{
			BPPret = 1;				
			break;
		}
		case YUV422:
		{
			BPPret = 2;				
			break;
		}
	}
	return BPPret;
}*/


bool VideoManInputFormat::validFormat()
{
	if ( width <= 0 || height <= 0)
		return false;
	if ( depth <= 0 || nChannels <= 0)
		return false;
/*	float BppCalc = calculateBpp( pixelFormats.formatIn );
	if ( BppCalc == -1 )
		return false;
	BppCalc = calculateBpp( pixelFormats.formatOut );
	if ( BppCalc == -1 )
		return false;*/
	return true;
}

/*float VideoManInputFormat::getBpp()
{
	return BppOut;
}*/

PIXEL_FORMAT VideoManInputFormat::getPixelFormatIn()
{
	return pixelFormats.formatIn;
}

PIXEL_FORMAT VideoManInputFormat::getPixelFormatOut()
{
	return pixelFormats.formatOut;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -