灰階的StringGrid值 |
答題得分者是:taishyang
|
5515531
一般會員 發表:19 回覆:44 積分:12 註冊:2008-04-16 發送簡訊給我 |
我要把一張灰階圖的值給秀出來~~
所以我寫了以下的程式 [code cpp] void __fastcall TForm1::Button1Click(TObject *Sender) { if(OpenPictureDialog1->Execute()) { Image1->Picture->LoadFromFile(OpenPictureDialog1->FileName); //open image1 /*-----------------------Set Grid1---------------------------*/ int count=1; Byte *ptr1; StringGrid1->ColCount = Image1->Width 1; StringGrid1->RowCount = Image1->Height 1; for (int y = 1 ; y <= Image1->Height ; y ) StringGrid1->Cells[0][y] = y; //Title for (int x = 1 ; x < Image1->Width*3 ; x =3) { StringGrid1->Cells[x][0] = x/3 1; //Title StringGrid1->Cells[x 1][0] = x/3 1; StringGrid1->Cells[x 2][0] = x/3 1; } //----------------------------------------------------------- for (int y = 1 ; y <= Image1->Height ; y ) { ptr1 = (Byte *)Image1->Picture->Bitmap->ScanLine[y-1]; for(int x = 1 ; x <= Image1->Width*3 ; x =3) { StringGrid1->Cells[count][y]=ptr1[(x-1)]; StringGrid1->Cells[count 1][y]=ptr1[(x-1) 1]; StringGrid1->Cells[count 2][y]=ptr1[(x-1) 2]; count =3; } count=1; } } } [/code] 但是卻出現錯誤耶~~ 出現Project Project1.exe raised exception class EInvalidGraphicOperation with message'.Process stopped. Use Step or Run to continue. 可不可以幫我稍微看一下 編輯記錄
5515531 重新編輯於 2008-09-29 16:42:57, 註解 無‧
|
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
for (int y = 1 ; y <= Image1->Height ; y )
for(int x = 1 ; x <= Image1->Width*3 ; x =3) for的終止範圍似乎有問題 ===================引 用 5515531 文 章=================== 我要把一張灰階圖的值給秀出來~~ 所以我寫了以下的程式 [code cpp] void __fastcall TForm1::Button1Click(TObject *Sender) { if(OpenPictureDialog1->Execute()) { Image1->Picture->LoadFromFile(OpenPictureDialog1->FileName); //open image1 /*-----------------------Set Grid1---------------------------*/ int count=1; Byte *ptr1; StringGrid1->ColCount = Image1->Width 1; StringGrid1->RowCount = Image1->Height 1; for (int y = 1 ; y <= Image1->Height ; y ) StringGrid1->Cells[0][y] = y; //Title for (int x = 1 ; x < Image1->Width*3 ; x =3) { StringGrid1->Cells[x][0] = x/3 1; //Title StringGrid1->Cells[x 1][0] = x/3 1; StringGrid1->Cells[x 2][0] = x/3 1; } //----------------------------------------------------------- for (int y = 1 ; y <= Image1->Height ; y ) { ptr1 = (Byte *)Image1->Picture->Bitmap->ScanLine[y-1]; for(int x = 1 ; x <= Image1->Width*3 ; x =3) { StringGrid1->Cells[count][y]=ptr1[(x-1)]; StringGrid1->Cells[count 1][y]=ptr1[(x-1) 1]; StringGrid1->Cells[count 2][y]=ptr1[(x-1) 2]; count =3; } count=1; } } } [/code] 但是卻出現錯誤耶~~ 出現Project Project1.exe raised exception class EInvalidGraphicOperation with message'.Process stopped. Use Step or Run to continue. 可不可以幫我稍微看一下 |
5515531
一般會員 發表:19 回覆:44 積分:12 註冊:2008-04-16 發送簡訊給我 |
恩恩~~後來又稍為嘗試了一下~~真的有點怪異
所以我又改了一些東西 [code cpp] void __fastcall TForm1::Button2Click(TObject *Sender) { COLORREF color1; byte R,G,B,gray; int count=0,sum=0,i; StringGrid1->RowCount=Bitmap->Height*Bitmap->Width; for(int y=0;y<=Bitmap->Height;y ) { for(int x=0;x<= Bitmap->Width;x ) { color1=Bitmap->Canvas->Pixels[x][y]; R=GetRValue(color1); G=GetGValue(color1); B=GetBValue(color1); gray=(R G B)/3; count ; StringGrid1->Cells[0][count]=count; StringGrid1->Cells[2][count]=gray; } } Series1->Add(gray,"",clBlue); } [/code] 我已經把灰階值顯示在第二行下 接下來可以教我如何把此值做統計並顯示在Chart裡嗎?? |
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
|
5515531
一般會員 發表:19 回覆:44 積分:12 註冊:2008-04-16 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |