程式執行時出現的視窗 |
答題得分者是:herbert2
|
913028
一般會員 發表:30 回覆:41 積分:19 註冊:2008-06-24 發送簡訊給我 |
|
herbert2
尊榮會員 發表:58 回覆:640 積分:894 註冊:2004-04-16 發送簡訊給我 |
|
913028
一般會員 發表:30 回覆:41 積分:19 註冊:2008-06-24 發送簡訊給我 |
===================引 用 herbert2 文 章=================== 您可能呼叫到一個尚不存在的物件! 例如: 在 .h 檔有宣告 TStringList *Ta; 但 .cpp 檔中沒有執行 new 便使用 Ta. 無程式碼是很難判斷錯誤原因的! ========================================= herbert2 你好: 這是我執行時,會有錯誤的程式碼。 以下是我引用此網站 richtop大大的程式碼 http://delphi.ktop.com.tw/board.php?cid=168&fid=921&tid=60924 [code cpp] void __fastcall TForm1::Button17Click(TObject *Sender) { findBoundary(Image2); } //--------------------------------------------------------------------------- void __fastcall TForm1::findBoundary(TImage *image) { int index; int x[2], y[2]; image->Picture->Bitmap->PixelFormat = pf24bit; Byte **ptr; ptr = new Byte*[image->Picture->Height]; for (int k=0; k ptr[k] = (Byte*) image->Picture->Bitmap->ScanLine[k]; // up bound bool skip = false; for (int row=0; row { index = 0; for (int col=0; col { if ( ptr[row][index]==255 ) // white point meeting { y[0] = row; skip = true; break; } index = 3; } if ( skip ) break; } // bottom bound skip = false; for (int row=image->Picture->Height-1; row>=0; row--) { index = 0; for (int col=0; col { if ( ptr[row][index]==255 ) // white point meeting { y[1] = row; skip = true; break; } index = 3; } if ( skip ) break; } // left bound skip = false; for (int col=0; col { index = col*3; for (int row=0; row { if ( ptr[row][index]==255 ) // white point meeting { x[0] = col; skip = true; break; } } if ( skip ) break; } // right bound skip = false; for (int col=image->Picture->Width-1; col>=0; col--) { index = col*3; for (int row=0; row { if ( ptr[row][index]==255 ) // white point meeting { x[1] = col; skip = true; break; } } if ( skip ) break; } image->Picture->Bitmap->Canvas->Pen->Color = clYellow; image->Picture->Bitmap->Canvas->MoveTo(0,y[0]);//上 image->Picture->Bitmap->Canvas->LineTo(image->Picture->Width-1,y[0]); image->Picture->Bitmap->Canvas->MoveTo(0,y[1]);//下 image->Picture->Bitmap->Canvas->LineTo(image->Picture->Width-1,y[1]); image->Picture->Bitmap->Canvas->Pen->Color = clBlue; image->Picture->Bitmap->Canvas->MoveTo(x[0],0);//左 image->Picture->Bitmap->Canvas->LineTo(x[0],image->Picture->Height-1); image->Picture->Bitmap->Canvas->MoveTo(x[1],0);//右 image->Picture->Bitmap->Canvas->LineTo(x[1],image->Picture->Height-1); ShowMessage("左上點 X= " IntToStr(x[0]) """ , ""Y= " IntToStr(y[0]) ""); ShowMessage("右上點 X= " IntToStr(x[1]) """ , ""Y= " IntToStr(y[0]) ""); ShowMessage("左下點 X= " IntToStr(x[0]) """ , ""Y= " IntToStr(y[1]) ""); ShowMessage("右下點 X= " IntToStr(x[1]) """ , ""Y= " IntToStr(y[1]) ""); delete [] ptr; } [/code] 謝謝
------
新手報到 |
herbert2
尊榮會員 發表:58 回覆:640 積分:894 註冊:2004-04-16 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |