我執行OPEN指令
然後畫面變成下圖
會有奇怪白點
請問一下為什麼會造成這樣的結果??
然後當我播放所開啟檔案以後白點依舊存在
如第二張圖如示
發表人 - billmin 於 2005/09/28 19:06:38
//--------------------------------------------------------------------------- #include
#pragma hdrstop #include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
int count=0; // 計算畫面數
int i,j; // 所需要的變數
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender)
{
if(OpenDialog1->Execute())
{
MediaPlayer1->FileName = OpenDialog1->FileName;
}
MediaPlayer1->Open();
//Edit1->Text=MediaPlayer1->Length;
//ScrollBar1->Enabled = true;
//ScrollBar1->SetFocus();
//ScrollBar1->Max = MediaPlayer1->Length;
//MediaPlayer1->Frames = 1;
//Edit2->Text = MediaPlayer1->Position;
MediaPlayer1->Display = Panel1; //Set display device to a TPanel }
//--------------------------------------------------------------------------- void __fastcall TForm1::MediaPlayer1Click(TObject *Sender,
TMPBtnType Button, bool &DoDefault)
{
MediaPlayer1->Frames = 100;
switch (Button)
{
case btPlay:
Timer1->Interval = 5;
Timer1->Enabled = true; break;
case btPause:
Timer1->Enabled = false;
break; }
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{ Graphics::TBitmap *Bmp= new Graphics::TBitmap;;
TCanvas *MyCanvas= new TCanvas;;
HDC dc = GetDC(Panel1->Handle);
TRect rect = Panel1->ClientRect;
MyCanvas->Handle = dc;
Bmp->Width = rect.Right - rect.Left;
Bmp->Height = rect.Bottom - rect.Top; Bmp->Canvas->CopyRect(rect,MyCanvas,rect);
Bmp->PixelFormat=pf24bit; //------------------------------------------------------- //---------------影像相減-------------------------------- Graphics::TBitmap *FullSearch_Bmp= new Graphics::TBitmap;;
FullSearch_Bmp->Assign(Bmp);
int MV[15][20][2], SAD[15][15];
int x,y,a,b; byte *ptr;
int frame_now[240][320];
int frame_next[240][320]; for(j=0;j< FullSearch_Bmp->Height;j++)
{
ptr = (Byte *)FullSearch_Bmp->ScanLine[j];
for(i=0;iWidth;i++)
{
if ((count%2)==0)
frame_now[j][i] = 0.299*ptr[i*3+2] +0.587*ptr[i*3+1]+0.114*ptr[i*3];
else
frame_next[j][i] = 0.299*ptr[i*3+2] +0.587*ptr[i*3+1]+0.114*ptr[i*3];
}
} for(j=0;jHeight;j++)
{
ptr = (Byte *)FullSearch_Bmp->ScanLine[j];
for(i=0;iWidth;i++)
{
ptr[i*3] = ptr[i*3+1] = ptr[i*3+2]=abs(frame_now[j][i]-frame_next[j][i]);
}
} //---------------------FULL SEARCH---------------------------------
/*i=0;
j=0;
int SADmin=10000000;
int MVx, MVy;
for(a=0;a<8;a++)
{
for(b=0;b<8;b++)
{
SAD[a][b] = 0;
for(x=0;x<16;x++)
{
for(y=0;y<16;y++)
{
SAD[a][b]=abs(frame_now[x+i][y+j]-frame_next[x+a][y+b]);
}
} if(SAD[a][b]Width-16;j+=16)
{
SADmin=10000000;
for(a=0;a<8;a++)
{
for(b=-7;b<+8;b++)
{
SAD[a][b+7] = 0;
for(x=0;x<16;x++)
{
for(y=0;y<16;y++)
{
SAD[a][b+7]+=abs(frame_now[x+i][y+j]-frame_next[x+i+a][y+j+b]);
}
} if(SAD[a][b+7]Width-16;
SADmin=10000000;
for(a=0;a<8;a++)
{
for(b=-7;b<1;b++)
{
for(x=0;x<16;x++)
{
SAD[a][b+7] = 0;
for(y=0;y<16;y++)
{
SAD[a][b+7]+=abs(frame_now[x+i][y+j]-frame_next[x+i+a][y+j+b]);
} if(SAD[a][b+7]Height/16-1][0] = MVx;
MV[0][FullSearch_Bmp->Height/16-1][1] = MVy; //===================== 補中間部分MB =====================
for(i=16;iHeight-16;i+=16)
{
for(j=16;jWidth-16;j+=16)
{
SADmin=1000000;
for(a=-7;a<8;a++)
{
for(b=-7;b<8;b++)
{
SAD[a+7][b+7]=0;
for(x=0;x<16;x++)
{
for(y=0;y<16;y++)
{
SAD[a+7][b+7]+=abs(frame_now[x+i][y+j]-frame_next[x+i+a][y+j+b]);
}
} if(SAD[a+7][b+7]Height-16;i+=16)
{
SADmin=10000000;
for(a=-7;a<8;a++)
{
for(b=0;b<8;b++)
{
SAD[a+7][b] = 0;
for(x=0;x<16;x++)
{
for(y=0;y<16;y++)
{
SAD[a+7][b]+=abs(frame_now[x+i][y+j]-frame_next[x+i+a][y+j+b]);
}
} if(SAD[a+7][b]Width-16;
for(i=16;iHeight-16;i+=16)
{
SADmin=10000000;
for(a=-7;a<8;a++)
{
for(b=-7;b<1;b++)
{
SAD[a+7][b+7] = 0;
for(x=0;x<16;x++)
{
for(y=0;y<16;y++)
{
SAD[a+7][b+7]+=abs(frame_now[x+i][y+j]-frame_next[x+i+a][y+j+b]); }
}
if(SAD[a+7][b+7]Height-16;
j=0;
SADmin=10000000;
for(a=-7;a<1;a++)
{
for(b=0;b<8;b++)
{
SAD[a+7][b] = 0;
for(x=0;x<16;x++)
{
for(y=0;y<16;y++)
{
SAD[a+7][b]+=abs(frame_now[x+i][y+j]-frame_next[x+i+a][y+j+b]);
}
} if(SAD[a+7][b]Height/16-1][0][0] = MVx;
MV[FullSearch_Bmp->Height/16-1][0][1] = MVy;
} //====================== 補最下面一列MB ================================
i=FullSearch_Bmp->Height-16;
for(j=16;jWidth-16;j+=16)
{
SADmin=10000000;
for(a=-7;a<1;a++)
{
for(b=-7;b<8;b++)
{
SAD[a+7][b+7] = 0;
for(x=0;x<16;x++)
{
for(y=0;y<16;y++)
{
SAD[a+7][b+7]+=abs(frame_now[x+i][y+j]-frame_next[x+i+a][y+j+b]);
}
} if(SAD[a+7][b+7]Height-16;
j=FullSearch_Bmp->Width-16;
SADmin=10000000;
for(a=-7;a<1;a++)
{
for(b=-7;b<1;b++)
{
SAD[a+7][b+7] = 0;
for(x=0;x<16;x++)
{ for(y=0;y<16;y++)
{
SAD[a+7][b+7]+=abs(frame_now[x+i][y+j]-frame_next[x+i+a][y+j+b]);
}
} if(SAD[a+7][b+7]Height/16-1][FullSearch_Bmp->Width/16-1][0] = MVx;
MV[FullSearch_Bmp->Height/16-1][FullSearch_Bmp->Width/16-1][1] = MVy; Image1->Picture->Bitmap->Assign(FullSearch_Bmp);
//=================以上為Full Search =========================
//=================把MV畫在畫布上==============================
Image1->Canvas->Pen->Width = 0.01;
Image1->Canvas->Pen->Color = clYellow;
for(j=0;j< FullSearch_Bmp->Height;j+=16)
{
for(i=0;i< FullSearch_Bmp->Width;i+=16)
{
Image1->Canvas->MoveTo(i, j);
Image1->Canvas->LineTo(i+MV[j/16][i/16][0], j+MV[j/16][i/16][1]);
}
}
//============================================================== */ Image1->Picture->Bitmap->Assign(FullSearch_Bmp); count++; Form1->DoubleBuffered=true ;
delete Bmp;
delete MyCanvas;
delete FullSearch_Bmp;
Form1->DoubleBuffered=true ; //讓畫面不再閃爍
}
//---------------------------------------------------------------------------
發表人 - billmin 於 2005/09/28 19:08:34