本帖最後由 in_dependent_ 於 2009-1-10 10:00 PM 編輯
void __fastcall TForm1::Button6Click(TObject *Sender)
{
int p[1000][1000];
int m[3][3]={-1,-1,-1,-1,8,-1,-1,-1,-1};
int low;
for(int i=0;i<Image1->Picture->Bitmap->Height;i++ )
{
for(int j=0;j<Image1->Picture->Bitmap->Width;j++)
{
p[j]=Image1->Canvas->Pixels[j];
}
}
for(int i=1;i<Image1->Picture->Bitmap->Height-1;i++ )
{
for(int j=1;j<Image1->Picture->Bitmap->Width-1;j++)
{
low=p[i-1][j-1]*m[0][0]+p[i-1][j]*m[0][1]+p[i-1][j+1]*m[0][2]+
p[j-1]*m[1][0]+p[j]*m[1][1]+p[j+1]*m[1][2]+
p[i+1][j-1]*m[2][0]+p[i+1][j]*m[2][1]+p[i+1][j+1]*m[2][2];
if(low>255)low=255;
if(low<0)low=0;
Image1->Canvas->Pixels[j]=low;
}
}
Image1->Refresh();
}
執行時會出錯錯誤訊息是 Project pHW3.exe raised exception class EStackOverfiow with message wuth 'Stack overflow'. Process stopped.Use step or Run to continue.
我找不出是哪邊錯誤
是否記憶體有宣告有問題,要改為動態
請高手大大們幫忙 修改 測試 感恩... |