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

📄 captiondemodlg.cpp

📁 电视字幕卡调用DLL模块
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	m_Scroll_FadeStep.SetScrollPos(255);
	m_text_fadestep.Format(TEXT("%d"),255);
	pICg2k->spv_fade_in_out(0xff);//键系数=255,处于完全fade in状态

//初始化fadein fadeout 执行速度设置
	m_Scroll_FadeSpeed.SetScrollRange(1,255);
	m_Scroll_FadeSpeed.SetScrollPos(1);
	m_text_fadespeed.Format(TEXT("%d"),1);

	pICg2k->spv_virtual_screen_freedom_pan_startxy(0,0);

//初始化完毕,停止旁通输出,将叠加图文的视频信号输出
    pICg2k->spv_enalbe_video_output( ON );

//初始化lock mode为内同步方式////////////////////////////////////////
	m_button_syn_external.SetCheck(0);
	m_button_syn_internal.SetCheck(1);
	pICg2k->spv_genlock(FALSE);
	
	UpdateData(FALSE);

/* ===============================================================================
	create test threads for multi-window, 2004-05-14 begin
   =============================================================================== */
	m_hThreadBlockHandle = CreateThread ( NULL, 0, CustomFlyBlockThreadFun, this, 0, NULL );		//
	if ( m_hThreadBlockHandle ==  NULL)													//	
	{
		AfxMessageBox ( "CreateThread ThreadFlying Block Error" );
		return FALSE;
	}

	m_hThreadWindow1Handle = CreateThread ( NULL, 0, CustomFlyWindow1ThreadFun,this, 0, NULL );		//
	if ( m_hThreadWindow1Handle  ==  NULL)													//	
	{
		AfxMessageBox ( "CreateThread ThreadWindow1 Error" );
		return FALSE;
	}
	m_hThreadWindow2Handle = CreateThread ( NULL, 0, CustomFlyWindow2ThreadFun,this, 0, NULL );
	if ( m_hThreadWindow2Handle  ==  NULL) 
	{
		AfxMessageBox ( "CreateThread ThreadWindow2 Error" );
		return FALSE;
	}
	m_hThreadWindow3Handle = CreateThread ( NULL, 0, CustomFlyWindow3ThreadFun,this, 0, NULL );
	if ( m_hThreadWindow3Handle  ==  NULL) 
	{
		AfxMessageBox ( "CreateThread ThreadWindow3 Error" );
		return FALSE;
	}
	m_hThreadWindow4Handle = CreateThread ( NULL, 0, CustomFlyWindow4ThreadFun,this, 0, NULL );
	if ( m_hThreadWindow4Handle  ==  NULL) 
	{
		AfxMessageBox ( "CreateThread ThreadWindow4 Error" );
		return FALSE;
	}
/*	create test threads for multi-window, 2004-05-14 end*/

/*
	m_hThreadWindow5Handle = CreateThread ( NULL, 0, CustomFlyWindow5ThreadFun,this, 0, NULL );
	if ( m_hThreadWindow5Handle  ==  NULL) 
	{
		AfxMessageBox ( "CreateThread ThreadWindow5 Error" );
		return FALSE;
	}
	m_hThreadWindow6Handle = CreateThread ( NULL, 0, CustomFlyWindow6ThreadFun,this, 0, NULL );
	if ( m_hThreadWindow6Handle  ==  NULL) 
	{
		AfxMessageBox ( "CreateThread ThreadWindow6 Error" );
		return FALSE;
	}
*/
	return TRUE;  // return TRUE  unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.
void CCaptionDemoDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CCaptionDemoDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}
BOOL yuvtouyvy(char *src);
void uyvytoyuv(char *src, char *dest);

void CCaptionDemoDlg::OnReadTgafile() 
{
	CString		GetFile;
	char		FileName[80];
	LPUSLONG	m_BufForTgaFileA = NULL;

	static char BASED_CODE szFilter[] = "Tga (*.tga)|*.tga|All Files (*.*)|*.*||";
	CFileDialog fileDlg (	TRUE, 
							NULL, 
							NULL, 
							OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, 
							szFilter,
							this );

	if (fileDlg.DoModal() == IDOK)
	{
		GetFile = fileDlg.GetFileName();
		sprintf(FileName, "%s", (LPCTSTR)GetFile);
    
			if (m_VideoType == PAL )
			{//pal制
				m_BufForTgaFileA = (LPUSLONG)VirtualAlloc(   NULL, 
															 PALVIDEOFRAME * 4, 
															 MEM_RESERVE|MEM_COMMIT,
															 PAGE_READWRITE );	
				if (!getFiles(FileName, m_BufForTgaFileA))
				{
					AfxMessageBox("File format Error!");
					VirtualFree(m_BufForTgaFileA, 0, MEM_RELEASE);
					return;
				}

				//从PC内存缓冲区向TM1300和PC的共享缓冲区拷贝:
				pICg2k->spv_copy_from_mem_to_virtual_buffer((LPUSLONG)m_BufForTgaFileA);

				// Here, assume update video buffer start from (0,0)
				//从TM1300和PC的共享缓冲区向TM1300中的图文缓冲区拷贝
				pICg2k->spv_update_virtual_buffer(0, 0, VIDEOWIDTH, PALVIDEOHEIGHT);
				VirtualFree(m_BufForTgaFileA, 0, MEM_RELEASE);			 	
			}
			else
			{//NTSC制
				m_BufForTgaFileA = (LPUSLONG)VirtualAlloc(   NULL, 
															 PALVIDEOFRAME * 4, 
															 MEM_RESERVE|MEM_COMMIT,
															 PAGE_READWRITE );	
				if (!getFiles(FileName, m_BufForTgaFileA))
				{
					AfxMessageBox("File format Error!");
					VirtualFree(m_BufForTgaFileA, 0, MEM_RELEASE);
					return;
				}

				//从PC内存缓冲区向TM1300和PC的共享缓冲区拷贝:
				pICg2k->spv_copy_from_mem_to_virtual_buffer((LPUSLONG)m_BufForTgaFileA);

				// Here, assume update video buffer start from (0,0)
				//从TM1300和PC的共享缓冲区向TM1300中的图文缓冲区拷贝
				pICg2k->spv_update_virtual_buffer( 0, 0, VIDEOWIDTH, NTSCVIDEOHEIGHT);

				VirtualFree(m_BufForTgaFileA, 0, MEM_RELEASE);			 	

			}//NTSC END

	}

}

// input video source select////////////////////////////////////////////
void CCaptionDemoDlg::OnRadioCvbs() 
{
	m_InputVideoType = CVBS;
	pICg2k->spv_switch_decoder_source(m_InputVideoType); // set input video source for cvbs

	if(m_BoardType == MAGICG_LE)
	{
			if (m_VideoType == PAL )
			{//pal制
				//for color adjust///////////////////////////////////////////////////////
				//初始化brightness
					m_Scroll_Bright.SetScrollRange(0,255);
					m_Scroll_Bright.SetScrollPos(138);
					m_text_bright.Format(TEXT("%d"), 138);
					pICg2k->spv_vo_bright(138);

				//初始化contrast
					m_Scroll_Contrast.SetScrollRange(0,255);
					m_Scroll_Contrast.SetScrollPos(72);
					m_text_contrast.Format(TEXT("%d"),72);
					pICg2k->spv_vo_contrast(72);

				//初始化Hue
					m_Scroll_Hue.SetScrollRange(0,255);
					m_Scroll_Hue.SetScrollPos(0);
					m_text_hue.Format(TEXT("%d"), 0);
					pICg2k->spv_vo_hue(0);

				//初始化Saturation
					m_Scroll_Saturation.SetScrollRange(0,255);
					m_Scroll_Saturation.SetScrollPos(62);
					m_text_saturation.Format(TEXT("%d"), 62);
					pICg2k->spv_vo_saturation(62);

				//初始化色度Gain
					maxgain =255;
					m_Scroll_Gain.SetScrollRange(0,maxgain);
					m_Scroll_Gain.SetScrollPos(180);
					m_text_gain.Format(TEXT("%d"), 180);
					pICg2k->spv_vo_gain(180);
			}
			else
			{//ntsc制 MAGICG_LE
				//for color adjust///////////////////////////////////////////////////////
				//初始化brightness
					m_Scroll_Bright.SetScrollRange(0,255);
					m_Scroll_Bright.SetScrollPos(147);
					m_text_bright.Format(TEXT("%d"), 147);
					pICg2k->spv_vo_bright(147);

				//初始化contrast
					m_Scroll_Contrast.SetScrollRange(0,255);
					m_Scroll_Contrast.SetScrollPos(76);
					m_text_contrast.Format(TEXT("%d"),76);
					pICg2k->spv_vo_contrast(76);

				//初始化Hue
					m_Scroll_Hue.SetScrollRange(0,255);
					m_Scroll_Hue.SetScrollPos(0);
					m_text_hue.Format(TEXT("%d"), 0);
					pICg2k->spv_vo_hue(0);

				//初始化Saturation
					m_Scroll_Saturation.SetScrollRange(0,255);
					m_Scroll_Saturation.SetScrollPos(64);
					m_text_saturation.Format(TEXT("%d"), 64);
					pICg2k->spv_vo_saturation(64);

				//初始化色度Gain
					maxgain =255;
					m_Scroll_Gain.SetScrollRange(0,maxgain);
					m_Scroll_Gain.SetScrollPos(178);
					m_text_gain.Format(TEXT("%d"), 178);
					pICg2k->spv_vo_gain(178);			
			}	
	}
	else if(m_BoardType == MAGICG_YUV)
	{
			if (m_VideoType == PAL )
			{//pal制 MAGICG_YUV
				//for color adjust///////////////////////////////////////////////////////
				//初始化brightness
					m_Scroll_Bright.SetScrollRange(0,255);
					m_Scroll_Bright.SetScrollPos(140);
					m_text_bright.Format(TEXT("%d"), 140);
					pICg2k->spv_vo_bright(140);

				//初始化contrast
					m_Scroll_Contrast.SetScrollRange(0,255);
					m_Scroll_Contrast.SetScrollPos(74);
					m_text_contrast.Format(TEXT("%d"),74);
					pICg2k->spv_vo_contrast(74);

				//初始化Hue
					m_Scroll_Hue.SetScrollRange(0,255);
					m_Scroll_Hue.SetScrollPos(0);
					m_text_hue.Format(TEXT("%d"), 0);
					pICg2k->spv_vo_hue(0);

				//初始化Saturation
					m_Scroll_Saturation.SetScrollRange(0,255);
					m_Scroll_Saturation.SetScrollPos(64);
					m_text_saturation.Format(TEXT("%d"), 64);
					pICg2k->spv_vo_saturation(64);

				//初始化色度Gain
					maxgain =255;
					m_Scroll_Gain.SetScrollRange(0,maxgain);
					m_Scroll_Gain.SetScrollPos(178);
					m_text_gain.Format(TEXT("%d"), 178);
					pICg2k->spv_vo_gain(178);
			}
			else
			{//ntsc制 MAGICG_YUV
				//for color adjust///////////////////////////////////////////////////////
				//初始化brightness
					m_Scroll_Bright.SetScrollRange(0,255);
					m_Scroll_Bright.SetScrollPos(140);
					m_text_bright.Format(TEXT("%d"), 140);
					pICg2k->spv_vo_bright(140);

				//初始化contrast
					m_Scroll_Contrast.SetScrollRange(0,255);
					m_Scroll_Contrast.SetScrollPos(74);
					m_text_contrast.Format(TEXT("%d"),74);
					pICg2k->spv_vo_contrast(74);

				//初始化Hue
					m_Scroll_Hue.SetScrollRange(0,255);
					m_Scroll_Hue.SetScrollPos(0);
					m_text_hue.Format(TEXT("%d"), 0);
					pICg2k->spv_vo_hue(0);

				//初始化Saturation
					m_Scroll_Saturation.SetScrollRange(0,255);
					m_Scroll_Saturation.SetScrollPos(64);
					m_text_saturation.Format(TEXT("%d"), 64);
					pICg2k->spv_vo_saturation(64);

				//初始化色度Gain
					maxgain =255;
					m_Scroll_Gain.SetScrollRange(0,maxgain);
					m_Scroll_Gain.SetScrollPos(178);
					m_text_gain.Format(TEXT("%d"), 178);
					pICg2k->spv_vo_gain(178);			
			}	
	}
	else
	{//MAGICGBOX
			if (m_VideoType == PAL )
			{//pal制
				//for color adjust///////////////////////////////////////////////////////
				//初始化brightness
					m_Scroll_Bright.SetScrollRange(0,255);
					m_Scroll_Bright.SetScrollPos(136);
					m_text_bright.Format(TEXT("%d"), 136);
					pICg2k->spv_vo_bright(136);

				//初始化contrast
					m_Scroll_Contrast.SetScrollRange(0,255);
					m_Scroll_Contrast.SetScrollPos(72);
					m_text_contrast.Format(TEXT("%d"),72);
					pICg2k->spv_vo_contrast(72);

				//初始化Hue
					m_Scroll_Hue.SetScrollRange(0,255);
					m_Scroll_Hue.SetScrollPos(0);
					m_text_hue.Format(TEXT("%d"), 0);
					pICg2k->spv_vo_hue(0);

				//初始化Saturation
					m_Scroll_Saturation.SetScrollRange(0,255);
					m_Scroll_Saturation.SetScrollPos(65);
					m_text_saturation.Format(TEXT("%d"), 65);
					pICg2k->spv_vo_saturation(65);

				//初始化色度Gain
					maxgain =255;
					m_Scroll_Gain.SetScrollRange(0,	maxgain);
					m_Scroll_Gain.SetScrollPos(180);
					m_text_gain.Format(TEXT("%d"), 180);
					pICg2k->spv_vo_gain(180);

			}
			else
			{//ntsc制
				//for color adjust///////////////////////////////////////////////////////
				//初始化brightness
					m_Scroll_Bright.SetScrollRange(0,255);
					m_Scroll_Bright.SetScrollPos(146);
					m_text_bright.Format(TEXT("%d"), 146);
					pICg2k->spv_vo_bright(146);

				//初始化contrast
					m_Scroll_Contrast.SetScrollRange(0,255);
					m_Scroll_Contrast.SetScrollPos(76);
					m_text_contrast.Format(TEXT("%d"),76);
					pICg2k->spv_vo_contrast(76);

				//初始化Hue
					m_Scroll_Hue.SetScrollRange(0,255);
					m_Scroll_Hue.SetScrollPos(0);
					m_text_hue.Format(TEXT("%d"), 0);
					pICg2k->spv_vo_hue(0);

				//初始化Saturation
					m_Scroll_Saturation.SetScrollRange(0,255);
					m_Scroll_Saturation.SetScrollPos(65);
					m_text_saturation.Format(TEXT("%d"), 65);
					pICg2k->spv_vo_saturation(65);

				//初始化色度Gain
					maxgain =255;
					m_Scroll_Gain.SetScrollRange(0,	maxgain);
					m_Scroll_Gain.SetScrollPos(180);
					m_text_gain.Format(TEXT("%d"), 180);
					pICg2k->spv_vo_gain(180);
			}	

	}
	UpdateData(FALSE);
}
void CCaptionDemoDlg::OnRadioYc() 
{
	m_InputVideoType = YC;
	pICg2k->spv_switch_decoder_source(m_InputVideoType);// set input video source for yc

	if(m_BoardType == MAGICG_LE)
	{
			if (m_VideoType == PAL )
			{//pal制
				//for color adjust///////////////////////////////////////////////////////
				//初始化brightness
					m_Scroll_Bright.SetScrollRange(0,255);
					m_Scroll_Bright.SetScrollPos(135);
					m_text_bright.Format(TEXT("%d"), 135);

⌨️ 快捷键说明

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