S
socat
Unregistered / Unconfirmed
GUEST, unregistred user!
void CChildView::OnSampleVideo()
{
// TODO: Add your command handler code here
ULONG m_ulSampleDone;
int m_ulRGBMax;
ULONG* pSamplePicture;
m_ulRGBMax = 0;
ULONG VideoLine,VideoCol;
ULONG VideoMode;
SFCG_GetVideoMode( VideoMode, m_uCardNum );
if( VideoMode )
{
VideoLine = 720;
VideoCol = 576;
}
else
{
VideoLine = 720;
VideoCol = 488;
}
m_str.Format(_T(" "));
m_StartEndTime_str.Format(_T(" "));
m_SpendTime_str.Format(_T(" "));
pSamplePicture = new ULONG[VideoLine*VideoCol];
/ mpled data
if( !SFCG_SetVideoSample(m_uCardNum) )
{
MessageBox( _T("Set video sample error!"),_T("Error") );
return;
}
while ( !SFCG_GetIfVideoSampleDone( m_ulSampleDone, m_uCardNum ) )
{
}
SFCG_GetVideoSampleData( pSamplePicture, m_uCardNum );
CClientDC dc(this);
if (m_hBitmap)
:eleteObject(m_hBitmap);
//成员变量 位图句柄,用于在视图重绘时
m_hBitmap = ::CreateCompatibleBitmap(dc.GetSafeHdc(),VideoLine,VideoCol);
if(!m_hBitmap) //生成句柄不成功
return;
CBitmap bmp;
bmp.Attach(m_hBitmap);
BITMAP bm;
unsigned int PixelBytes = 0;
unsigned int i;
bmp.GetBitmap(&bm);
BYTE* lpBits = NULL;
BYTE r,g,b;
switch(bm.bmBitsPixel)
{
case 16: // R:G:B = 5:6:5
PixelBytes = 2;
lpBits = new BYTE[bm.bmWidth*bm.bmHeight*PixelBytes];
for(i = 0;i<VideoCol*VideoLine;i++)
{
r = BYTE(pSamplePicture>>16);
//Get Red Component
g = BYTE(pSamplePicture>>8);
//Get Green Component
b = BYTE(pSamplePicture); //Get Blue Component
lpBits[2*i] = (0xe0&(g<<3))|(b>>3);
lpBits[2*i+1] = (r&0xf8)|(g>>5);
}
break;
case 24:
PixelBytes = 3;
// R:G:B = 8:8:8
lpBits = new BYTE[bm.bmWidth*bm.bmHeight*PixelBytes];
for(i = 0;i<VideoCol*VideoLine;i++)
{
r = BYTE(pSamplePicture>>16);
//Get Red Component
g = BYTE(pSamplePicture>>8);
//Get Green Component
b = BYTE(pSamplePicture); //Get Blue Component
lpBits[3*i] = b;
lpBits[3*i+1] = g;
lpBits[3*i+2] = r;
}
break;
default:
break;
}
if(lpBits) // Not 32 bits true color
bmp.SetBitmapBits(bm.bmWidth*bm.bmHeight*PixelBytes,lpBits);
else
// 32 bits true color
bmp.SetBitmapBits(VideoCol*VideoLine*4,pSamplePicture);
// Display sampled picture
CDC mem;
mem.CreateCompatibleDC(&dc);
CBitmap* pOld = mem.SelectObject(&bmp);
dc.BitBlt(0,0,VideoLine,VideoCol,&mem,0,0,SRCCOPY);
mem.SelectObject(pOld);
mem.DeleteDC();
bmp.Detach();
if(lpBits)delete lpBits;
delete pSamplePicture;
}
是by1000字幕卡编程的问题, 帮忙翻译为delphi语言 谢谢了~ 我实在搞不定了~
或者能提供by1000采集卡截图功能的函数或者demo也可以~ 谢谢~
{
// TODO: Add your command handler code here
ULONG m_ulSampleDone;
int m_ulRGBMax;
ULONG* pSamplePicture;
m_ulRGBMax = 0;
ULONG VideoLine,VideoCol;
ULONG VideoMode;
SFCG_GetVideoMode( VideoMode, m_uCardNum );
if( VideoMode )
{
VideoLine = 720;
VideoCol = 576;
}
else
{
VideoLine = 720;
VideoCol = 488;
}
m_str.Format(_T(" "));
m_StartEndTime_str.Format(_T(" "));
m_SpendTime_str.Format(_T(" "));
pSamplePicture = new ULONG[VideoLine*VideoCol];
/ mpled data
if( !SFCG_SetVideoSample(m_uCardNum) )
{
MessageBox( _T("Set video sample error!"),_T("Error") );
return;
}
while ( !SFCG_GetIfVideoSampleDone( m_ulSampleDone, m_uCardNum ) )
{
}
SFCG_GetVideoSampleData( pSamplePicture, m_uCardNum );
CClientDC dc(this);
if (m_hBitmap)
:eleteObject(m_hBitmap);
//成员变量 位图句柄,用于在视图重绘时
m_hBitmap = ::CreateCompatibleBitmap(dc.GetSafeHdc(),VideoLine,VideoCol);
if(!m_hBitmap) //生成句柄不成功
return;
CBitmap bmp;
bmp.Attach(m_hBitmap);
BITMAP bm;
unsigned int PixelBytes = 0;
unsigned int i;
bmp.GetBitmap(&bm);
BYTE* lpBits = NULL;
BYTE r,g,b;
switch(bm.bmBitsPixel)
{
case 16: // R:G:B = 5:6:5
PixelBytes = 2;
lpBits = new BYTE[bm.bmWidth*bm.bmHeight*PixelBytes];
for(i = 0;i<VideoCol*VideoLine;i++)
{
r = BYTE(pSamplePicture>>16);
//Get Red Component
g = BYTE(pSamplePicture>>8);
//Get Green Component
b = BYTE(pSamplePicture); //Get Blue Component
lpBits[2*i] = (0xe0&(g<<3))|(b>>3);
lpBits[2*i+1] = (r&0xf8)|(g>>5);
}
break;
case 24:
PixelBytes = 3;
// R:G:B = 8:8:8
lpBits = new BYTE[bm.bmWidth*bm.bmHeight*PixelBytes];
for(i = 0;i<VideoCol*VideoLine;i++)
{
r = BYTE(pSamplePicture>>16);
//Get Red Component
g = BYTE(pSamplePicture>>8);
//Get Green Component
b = BYTE(pSamplePicture); //Get Blue Component
lpBits[3*i] = b;
lpBits[3*i+1] = g;
lpBits[3*i+2] = r;
}
break;
default:
break;
}
if(lpBits) // Not 32 bits true color
bmp.SetBitmapBits(bm.bmWidth*bm.bmHeight*PixelBytes,lpBits);
else
// 32 bits true color
bmp.SetBitmapBits(VideoCol*VideoLine*4,pSamplePicture);
// Display sampled picture
CDC mem;
mem.CreateCompatibleDC(&dc);
CBitmap* pOld = mem.SelectObject(&bmp);
dc.BitBlt(0,0,VideoLine,VideoCol,&mem,0,0,SRCCOPY);
mem.SelectObject(pOld);
mem.DeleteDC();
bmp.Detach();
if(lpBits)delete lpBits;
delete pSamplePicture;
}
是by1000字幕卡编程的问题, 帮忙翻译为delphi语言 谢谢了~ 我实在搞不定了~
或者能提供by1000采集卡截图功能的函数或者demo也可以~ 谢谢~