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

關於RGB的一個小問題

尚未結案
pixel
一般會員


發表:4
回覆:1
積分:1
註冊:2003-10-06

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-10-09 17:49:30 IP:211.22.xxx.xxx 未訂閱
自己想寫一個將Image1的RGB data讀出的動作, 為什麼我把Image1->Picture->Bitmap->Assign(pBitmap1);後 pBitmap1->Width是0 是哪邊有問題嗎?? 另外我若想在ImageArray1對RGB做處理再重填會去pBitmap最後show在Image1上 這程式該如何寫呢??    __fastcall TForm1::TForm1(TComponent* Owner)         : TForm(Owner) {    pBitmap1=new Graphics::TBitmap(); Image1->Picture->Bitmap->Assign(pBitmap1); Height=Width=256;    //建立一個儲存RGB的陣列 ImageArray1=new Byte *[Width];    for(int i=0;iPixelFormat = pf32bit; TColor *ptr; for(int y=0;yScanLine[y]; for(int x=0;xWidth;x ) { ImageArray1[x][y]=GetRValue(ptr[x]); ImageArray1[x][y]=GetGValue(ptr[x]); ImageArray1[x][y]=GetBValue(ptr[x]); } } ]
taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-10-09 17:59:22 IP:140.135.xxx.xxx 未訂閱
pixel您好: 請參考下面的聯結做適當的修改 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=37787 謝謝您的配合 下面是範例程式您參考看看 < class="code"> //---取出圖片的RGB值並存入R[],G[],B[]中 byte R[4800],G[4800],B[4800],*ptr; Graphics::TBitmap* BMP=new Graphics::TBitmap(); BMP->LoadFromFile("1.bmp"); for (int y=0; yHeight; y++) { ptr=(Byte*)BMP->ScanLine[y]; for (int x=0; xWidth; x++) { B[x+80*y]=ptr[x*3]; G[x+80*y]=ptr[x*3+1]; R[x+80*y]=ptr[x*3+2]; } } delete BMP; //-----秀出----------------- Graphics::TBitmap* BMP1=new Graphics::TBitmap(); BMP1->Height=60; BMP1->Width=80; for (int y=0;yHeight ;y++) { for (int x=0;xWidth ;x++) { BMP1->Canvas->Pixels[x][y]=TColor(RGB(R[x+80*y],G[x+80*y],B[x+80*y])); } } Image1->Picture->Assign(BMP1); delete BMP1; [Source如下] 順心 發表人 -
系統時間:2024-05-05 18:29:51
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!