線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1232
推到 Plurk!
推到 Facebook!

程式執行時出現的視窗

答題得分者是:herbert2
913028
一般會員


發表:30
回覆:41
積分:19
註冊:2008-06-24

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-10-28 16:05:41 IP:163.23.xxx.xxx 訂閱
各位大大你們好:
我在執行程式時compiler可以過,但是按到一個固定的按鈕,即出現以下視窗



請問這是什麼問題呢?

請大大們幫幫我解決這個問題..感謝


終於用好了 感謝 herbert2 大大 幫忙~
------
新手報到
編輯記錄
913028 重新編輯於 2008-10-31 21:55:19, 註解 無‧
herbert2
尊榮會員


發表:58
回覆:640
積分:894
註冊:2004-04-16

發送簡訊給我
#2 引用回覆 回覆 發表時間:2008-10-29 08:54:07 IP:211.72.xxx.xxx 訂閱
您可能呼叫到一個尚不存在的物件!
例如:
在 .h 檔有宣告 TStringList *Ta;
但 .cpp 檔中沒有執行 new 便使用 Ta.
無程式碼是很難判斷錯誤原因的!
913028
一般會員


發表:30
回覆:41
積分:19
註冊:2008-06-24

發送簡訊給我
#3 引用回覆 回覆 發表時間:2008-10-29 21:39:08 IP:118.170.xxx.xxx 訂閱

===================引 用 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; kHeight; k )
ptr[k] = (Byte*) image->Picture->Bitmap->ScanLine[k];

// up bound
bool skip = false;
for (int row=0; rowHeight; row )
{
index = 0;
for (int col=0; colWidth; 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; colWidth; 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; colWidth; col )
{
index = col*3;
for (int row=0; rowHeight; 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; rowHeight; 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

發送簡訊給我
#4 引用回覆 回覆 發表時間:2008-11-05 16:46:12 IP:211.72.xxx.xxx 訂閱
您的 Image 格式是 24 bit 的嗎?
若不是, ptr[row][index] 會超出範圍而引起錯誤!
index = 3 是跳 3 Byte (24 bit) 的意思, 若 Image 是 16 bit, 就跳到圖外去了!
系統時間:2024-05-04 22:30:46
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!