多媒体卡编程, C语言翻译为DELPHI语言 简单问题 高分(300分)

  • 主题发起人 主题发起人 socat
  • 开始时间 开始时间
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)
::DeleteObject(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&amp;(g<<3))|(b>>3);
lpBits[2*i+1] = (r&amp;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(&amp;dc);
CBitmap* pOld = mem.SelectObject(&amp;bmp);
dc.BitBlt(0,0,VideoLine,VideoCol,&amp;mem,0,0,SRCCOPY);
mem.SelectObject(pOld);
mem.DeleteDC();
bmp.Detach();

if(lpBits)delete lpBits;
delete pSamplePicture;

}

是by1000字幕卡编程的问题, 帮忙翻译为delphi语言 谢谢了~ 我实在搞不定了~
或者能提供by1000采集卡截图功能的函数或者demo也可以~ 谢谢~
 
翻译什么啊,直接做成dll到delphi里调用就行了。
 
这个本身就是字幕卡提供的dll的c语言调用, 但是不是很明白它的原理,也不知道该怎么编程实现它, 现在需要的功能是,采集一帧图片 但是采集卡的SDK并不支持直接获取一帧图片,只提供了,获取一个像素点的ARGB值,或者一帧的某一行的采样, 不知道该怎么截图
 
后退
顶部