ScrollBar移動時,畫面不會更新 |
答題得分者是:syntax
|
mynameisoa
一般會員 發表:4 回覆:8 積分:2 註冊:2008-10-07 發送簡訊給我 |
請問各位先進,我的程式哪邊出了問題?
感謝各位高手的幫忙... 以下為我的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 ptr = (Byte*)TheBitmap->ScanLine[y]; tptr = (Byte*)TempBitmap->ScanLine[y]; for(int x=0 ; 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); } |
syntax
尊榮會員 發表:26 回覆:1139 積分:1258 註冊:2002-04-23 發送簡訊給我 |
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 發送簡訊給我 |
先感謝syntax大的回覆...
你提供的以下四個,前三個ThresholdDlg有包含... 其中用了Refresh,在移動ScrollBar後,畫面有重新掃的感覺... 但是Image1依舊還是原本讀入的那張圖,是我程式寫法有問題嗎? ===================引 用 syntax 文 章=================== ThresholdDlg->Update ThresholdDlg->Refresh ThresholdDlg->Paint ThresholdDlg->Validate 試過嗎?(找一個 ThresholdDlg 有包含的) |
da76982396
一般會員 發表:0 回覆:1 積分:0 註冊:2008-10-13 發送簡訊給我 |
|
mynameisoa
一般會員 發表:4 回覆:8 積分:2 註冊:2008-10-07 發送簡訊給我 |
我後來自己改一改成功了...
附上改過的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 ; y ptr = (Byte*)TheBitmap->ScanLine[y]; tptr = (Byte*)TempBitmap->ScanLine[y]; for(int x=0 ; 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] |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |