請問關於RGB的數值 |
尚未結案
|
sumh
一般會員 發表:1 回覆:2 積分:0 註冊:2005-04-26 發送簡訊給我 |
方法一
TColor a = Image1->Canvas->Pixels[X][Y]; unsigned char b; //rgb value b = char(a); Label3->Caption = "R: " IntToStr(int(b)); a >>= 8; b = char(a); Label4->Caption = "G: " IntToStr(int(b)); a >>= 8; b = char(a); Label5->Caption = "B: " IntToStr(int(b));================================================================ 方法二 ptr = (Byte *)bmp->ScanLine[r];================================================================ 想要問一下針對同一張圖 這兩種方法取出的RGB數值為何會不同呢?? 感謝大大的回答 發表人 - sumh 於 2005/06/01 23:20:41 |
poaivy
中階會員 發表:40 回覆:78 積分:53 註冊:2004-08-09 發送簡訊給我 |
您好
根據我所測試的結果並沒有所謂的不一樣發生
以下是我測試的方式
< class="code">
void __fastcall TForm1::Image1MouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
TColor a = Image1->Canvas->Pixels[X][Y];
unsigned char b; //rgb value
b = char(a);
Label3->Caption = "R: " IntToStr(int(b));
a >>= 8;
b = char(a);
Label4->Caption = "G: " IntToStr(int(b));
a >>= 8;
b = char(a);
Label5->Caption = "B: " IntToStr(int(b));
Graphics::TBitmap *bmp=new Graphics::TBitmap();
bmp->Assign(Image1->Picture->Bitmap);
BYTE *ptr;
bmp->PixelFormat=pf24bit;
ptr = (Byte *)bmp->ScanLine[Y];
Label1->Caption="G: " AnsiString( ptr[X*3 1]);
Label2->Caption="R: " AnsiString( ptr[X*3 2]);
Label6->Caption="B: " AnsiString( ptr[X*3]);
delete bmp; 所以應該不會有你所說的情形發生吧^^
|
m58610
初階會員 發表:22 回覆:83 積分:36 註冊:2003-09-07 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |