void CPictureAreaMove::OnPictureAreaMoveSelPic() 
{
CBitmap * pBitmap ;
pBitmap = new CBitmap;
CTgaReader tgaReader;
BITMAP bm; CString strFileName;
POSITION posFile;
ULONG *pPicture,ulLeftDistance,ulUpDistance;
unsigned int i,j,k; CString strErr;
CFileDialog dlg(TRUE,
NULL,
_T("*.tga"),
        OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY|OFN_NOREADONLYRETURN ,
_T("Picture Files (*.tga) | *.tga | ")
        _T("All Files (*.*) | *.* ||")); i = 0; if ( dlg.DoModal()==IDOK )
{
if( wrLong )
delete wrLong; wrLong = new ULONG[ BURST_LENGTH*BURST_NO ];
SFCG_SetVideoBase( 0, m_uiCardNumber ); posFile = dlg.GetStartPosition();
while( posFile )
{
strFileName = dlg.GetNextPathName( posFile );
tgaReader.LoadImage(strFileName,pBitmap);
pBitmap->GetBitmap(&bm);
pPicture = new ULONG[ bm.bmWidth*bm.bmHeight ];
pBitmap ->GetBitmapBits(bm.bmWidth*bm.bmHeight*4,pPicture); if( BURST_LENGTH > bm.bmWidth )
ulLeftDistance = ( BURST_LENGTH - bm.bmWidth ) / 2;
else
ulLeftDistance = 0;

if( BURST_NO > bm.bmHeight )
ulUpDistance = ( BURST_NO - bm.bmHeight ) / 2;
else
ulUpDistance = 0; for( j=0;j<BURST_NO;j++ )
{
if( ( j < ( bm.bmHeight + ulUpDistance ) ) && ( j >= ulUpDistance ))
{
for( k=0; k<BURST_LENGTH; k++ )
if( ( k < ( bm.bmWidth + ulLeftDistance ) ) && ( k >= ulLeftDistance ) )
wrLong[ j*BURST_LENGTH + k ] = ( pPicture[ ( j - ulUpDistance )*bm.bmWidth + k - ulLeftDistance ] );
else
wrLong[ j*BURST_LENGTH + k ] = 0;
}
else
for( k=0; k<BURST_LENGTH; k++ )
wrLong[ j*BURST_LENGTH + k ] = 0; }
Sleep(100) ; for( j=0;j<BURST_NO;j++ )
SFCG_SetRectangle( 0,j,720,1,&wrLong[ j*BURST_LENGTH ], m_uiCardNumber );
delete [] pPicture;
} } delete pBitmap;
}void CPictureAreaMove::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
// TODO: Add your message handler code here and/or call default

m_nMoveStep = m_SpeedSel.GetScrollPos();
if( nSBCode == SB_LINELEFT )
m_nMoveStep--;
else
if( nSBCode == SB_LINERIGHT )
m_nMoveStep++;
else
if( nSBCode == SB_PAGELEFT )
m_nMoveStep -= 4;
else
if( nSBCode == SB_PAGERIGHT )
m_nMoveStep += 4; m_nMoveStep = min( 20,max( m_nMoveStep,1 ) );
m_SpeedSel.SetScrollPos(m_nMoveStep); CString str;
str.Format(_T("Speed Sel  %d  "),m_nMoveStep);

GetDlgItem(IDC_STATIC_AREA_MOVE_SPEED_SEL)->SetWindowText(str);

UpdateData(); CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}void CPictureAreaMove::PostNcDestroy() 
{
OnAreaMoveStop();
m_iMoving = MOVE_STOP;
::Sleep(100);  //Wait for thread safety quit CloseHandle(m_event); AreaMove(0);
AreaMove(1);
delete [] wrLong;  
wrLong = NULL; CDialog::PostNcDestroy();
}
/*
   视频区域移动函数,在线程中调用
   参数为场号,如果是奇数则写偶数场,如果是偶数则写奇数场
*/
void CPictureAreaMove::AreaMove(ULONG fieldNo)
{
    int j;
ULONG test[720];
if(!wrLong)return; switch( m_ulMoveDiretion )
{
case 0:
goto still; //如果停止移动则静止显示
break; case 1 :// Up
m_ulMoveDiretionLast = m_ulMoveDiretion;
m_ulFieldNoLast = fieldNo; m_Up += m_nMoveStep;
m_Up = m_Up % m_VideoCol;
for( j = ( fieldNo + 1 )% 2;j<m_VideoCol;j+=2 )
{
    if( ( j + m_Up ) < m_VideoCol )
    memcpy(test,&wrLong[( j + m_Up )*720],720*4);
    else
    memcpy(test,&wrLong[( j + m_Up-m_VideoCol )*720],720*4);
    SFCG_SetRectangle(0,j,720,1,test, m_uiCardNumber);
}

break; case 2 :// Down
m_ulMoveDiretionLast = m_ulMoveDiretion;
m_ulFieldNoLast = fieldNo; m_Up -= m_nMoveStep;
if( m_Up < 0 )
m_Up = m_Up + m_VideoCol;
m_Up = m_Up % m_VideoCol;
for( j = ( fieldNo + 1 )% 2;j<m_VideoCol;j+=2 )
{
    if( ( j + m_Up ) < m_VideoCol )
    memcpy(test,&wrLong[( j + m_Up )*720],720*4);
    else
      memcpy(test,&wrLong[( j + m_Up-m_VideoCol )*720],720*4);
    SFCG_SetRectangle(0,j,720,1,test, m_uiCardNumber);
}

break; case 3 :
m_ulMoveDiretionLast = m_ulMoveDiretion;
m_ulFieldNoLast = fieldNo; m_Left -= m_nMoveStep;
if( m_Left < 0 )
m_Left = 720 + m_Left;
for( j = ( fieldNo + 1 )% 2;j<m_VideoCol;j+=2 )
{
        memcpy(test,&wrLong[ j*720+m_Left],(720-m_Left)*4);
        memcpy(&test[720-m_Left],&wrLong[ j*720],m_Left*4);
        SFCG_SetRectangle(0,j ,720,1,test, m_uiCardNumber);
}

break; case 4 :
m_ulMoveDiretionLast = m_ulMoveDiretion;
m_ulFieldNoLast = fieldNo; m_Left += m_nMoveStep;
m_Left = m_Left % 720; for( j = ( fieldNo + 1 )% 2;j<m_VideoCol;j+=2 )
{
        memcpy(test,&wrLong[ j*720+m_Left],(720-m_Left)*4);
        memcpy(&test[720-m_Left],&wrLong[ j*720],m_Left*4);
        SFCG_SetRectangle(0,j ,720,1,test, m_uiCardNumber);
}

break;
}
return;still:
switch( m_ulMoveDiretionLast )
{
case 0:
break;
case 1:
case 2:
for( j = m_ulFieldNoLast% 2;j<m_VideoCol;j+=2 )
{
if( ( j + m_Up ) < m_VideoCol )
memcpy(test,&wrLong[( j + m_Up )*720],720*4);
else
memcpy(test,&wrLong[( j + m_Up-m_VideoCol )*720],720*4);
SFCG_SetRectangle(0,j,720,1,test, m_uiCardNumber);
}
break;
case 3:
    case 4:
        for( j = m_ulFieldNoLast% 2;j<m_VideoCol;j+=2 )
{
    memcpy(test,&wrLong[ j*720+m_Left],(720-m_Left)*4);
    memcpy(&test[720-m_Left],&wrLong[ j*720],m_Left*4);
    SFCG_SetRectangle(0,j ,720,1,test, m_uiCardNumber);
}
    break;
}
m_ulMoveDiretionLast = m_ulMoveDiretion;
}