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

ScrollBar移動時,畫面不會更新

答題得分者是:syntax
mynameisoa
一般會員


發表:4
回覆:8
積分:2
註冊:2008-10-07

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-10-14 00:56:52 IP:163.13.xxx.xxx 訂閱
請問各位先進,我的程式哪邊出了問題?

感謝各位高手的幫忙...

以下為我的code
[code c#]
void __fastcall TThresholdDlg::ScrollBar1Change(TObject *Sender)
{
int Thd; //臨界值
Graphics::TBitmap *TheBitmap, *TempBitmap;
Byte *ptr, *tptr;
Edit1->Text = IntToStr(ScrollBar1->Position) ;
//指向二值化對話盒的影像
TheBitmap=ThresholdDlg->Image1->Picture->Bitmap;
TheBitmap->PixelFormat=pf24bit;
//指向form1的原始影像
TempBitmap=Form1->OrgBitmap;
TempBitmap->PixelFormat=pf24bit;
//獲得捲軸位置
Thd=(int)ScrollBar1->Position;
//執行二值化
for(int y ; yHeight ; y ){
ptr = (Byte*)TheBitmap->ScanLine[y];
tptr = (Byte*)TempBitmap->ScanLine[y];
for(int x=0 ; xWidth ; x ){
ptr[3*x] = (tptr[3*x]<=Thd ? 0 :255);
ptr[3*x 1] = (tptr[3*x 1]<=Thd ? 0 :255);
ptr[3*x 2] = (tptr[3*x 2]<=Thd ? 0 :255);
}
}
Image1->Picture->Assign(TheBitmap);
}
[/code]
syntax
尊榮會員


發表:26
回覆:1139
積分:1258
註冊:2002-04-23

發送簡訊給我
#2 引用回覆 回覆 發表時間:2008-10-14 08:03:04 IP:118.231.xxx.xxx 訂閱

ThresholdDlg->Update

ThresholdDlg->Refresh

ThresholdDlg->Paint

ThresholdDlg->Validate

試過嗎?(找一個 ThresholdDlg 有包含的)
===================引 用 mynameisoa 文 章===================
請問各位先進,我的程式哪邊出了問題?

感謝各位高手的幫忙...

以下為我的code
[code c#]
void __fastcall TThresholdDlg::ScrollBar1Change(TObject *Sender)
{
int Thd; //臨界值
Graphics::TBitmap *TheBitmap, *TempBitmap;
Byte *ptr, *tptr;
Edit1->Text = IntToStr(ScrollBar1->Position) ;
//指向二值化對話盒的影像
TheBitmap=ThresholdDlg->Image1->Picture->Bitmap;
TheBitmap->PixelFormat=pf24bit;
//指向form1的原始影像
TempBitmap=Form1->OrgBitmap;
TempBitmap->PixelFormat=pf24bit;
//獲得捲軸位置
Thd=(int)ScrollBar1->Position;
//執行二值化
for(int y ; y
[/code]
mynameisoa
一般會員


發表:4
回覆:8
積分:2
註冊:2008-10-07

發送簡訊給我
#3 引用回覆 回覆 發表時間:2008-10-14 14:40:04 IP:163.13.xxx.xxx 訂閱
先感謝syntax大的回覆...

你提供的以下四個,前三個ThresholdDlg有包含...

其中用了Refresh,在移動ScrollBar後,畫面有重新掃的感覺...

但是Image1依舊還是原本讀入的那張圖,是我程式寫法有問題嗎?

===================引 用 syntax 文 章===================

ThresholdDlg->Update

ThresholdDlg->Refresh

ThresholdDlg->Paint

ThresholdDlg->Validate

試過嗎?(找一個 ThresholdDlg 有包含的)
da76982396
一般會員


發表:0
回覆:1
積分:0
註冊:2008-10-13

發送簡訊給我
#4 引用回覆 回覆 發表時間:2008-10-14 21:59:24 IP:140.118.xxx.xxx 訂閱
您的問題,小弟也剛遇到過
以下是我的解決方法..
您試試看!
[code cpp]
請在此區域輸入程式碼
[/code]
先叫一個 Image2
在第25行 Image1->Picture->Assign(TheBitmap);
改成 Image2->Picture->Assign(TheBitmap);
delete TheBitmap;

因為若妳在二值化的圖丟給 Image1,你ScrollBar拉動時,會重複抓以被二值化的圖

mynameisoa
一般會員


發表:4
回覆:8
積分:2
註冊:2008-10-07

發送簡訊給我
#5 引用回覆 回覆 發表時間:2008-10-14 22:05:15 IP:163.13.xxx.xxx 訂閱
我後來自己改一改成功了...

附上改過的code給大家參考...

感謝回覆的大家...

[code cpp]
void __fastcall TThresholdDlg::ScrollBar1Change(TObject *Sender)
{
int Thd;//臨界值
Graphics::TBitmap *TheBitmap, *TempBitmap, *OutBitmap;
Byte *ptr, *tptr;
Edit1->Text = IntToStr(ScrollBar1->Position) ;
//指向二值化對話盒的影像
TheBitmap=Image1->Picture->Bitmap;
TheBitmap->PixelFormat=pf24bit;
//指向form1的原始影像
TempBitmap=Form1->OrgBitmap;
TempBitmap->PixelFormat=pf24bit;
//獲得捲軸位置
Thd=(int)ScrollBar1->Position;
//執行二值化
for(int y=0 ; yHeight ; y ){
ptr = (Byte*)TheBitmap->ScanLine[y];
tptr = (Byte*)TempBitmap->ScanLine[y];
for(int x=0 ; xWidth ; x ){
ptr[3*x] = (tptr[3*x]<=Thd ? 0 :255);
ptr[3*x 1] = (tptr[3*x 1]<=Thd ? 0 :255);
ptr[3*x 2] = (tptr[3*x 2]<=Thd ? 0 :255);
OutBitmap = TheBitmap;
}
}
Image1->Picture->Assign(OutBitmap);
ThresholdDlg->Refresh();
}

[/code]
系統時間:2024-04-20 12:55:48
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!