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

請問TBitmap的問題~謝謝

尚未結案
isspice
一般會員


發表:23
回覆:12
積分:7
註冊:2004-04-19

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-04-24 15:36:11 IP:140.125.xxx.xxx 未訂閱
程式如下 Graphics::TBitmap *TheImage = new Graphics::TBitmap; TheImage->PixelFormat = pf8bit; TheImage->Height = 240; TheImage->Width =320; 請問今天我有一個矩陣byte a[240][320]; 我要將他Assign到TheImage裡並且顯示~~~請問我該怎做呢~~??? 我之前有做過~~到是好像是影像沒有檔頭所以都沒辦法顯示~~都必須先Assign 一張圖到TheImage裡然後利用指標改變它的值才行~~所以覺得很怪~~ 請問高手有沒有啥高招呢~~謝謝~~是不是檔頭那邊少了啥???謝謝~~~
jim006
一般會員


發表:22
回覆:25
積分:9
註冊:2004-01-14

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-04-24 16:01:47 IP:218.162.xxx.xxx 未訂閱
isspice 您好:    你因該是說你想要把矩陣中的東西存在一張圖檔裡面對吧...如果是這樣的話.....試試看用這個,希望能幫到你..........tks ^^ for (int i=0;i< TheImage->Height;i++) {   for (int j=0;jWidth ;j ) TheImage->Canvas->Pixels[x][y]=a[x][y]; } Image1->Canvas->Draw(0,0,TheImage);
isspice
一般會員


發表:23
回覆:12
積分:7
註冊:2004-04-19

發送簡訊給我
#3 引用回覆 回覆 發表時間:2004-04-24 17:05:15 IP:140.125.xxx.xxx 未訂閱
您好~~我剛照你的意思做但是還是沒有東西耶~~且會出錯~~ 訊息是::Assign unsignchar to Tcolor Graphics::TBitmap *TheBmp = new Graphics::TBitmap; Byte a[100][100]={0}; TheBmp->Width = 100; TheBmp->Height = 100; TheBmp->PixelFormat = pf8bit; fill(*a,*a 100*100,25); //將全部設為25 //TheBmp = Image1->Picture->Bitmap; for (int y=0;y< TheBmp->Height;y ) { for (int x=0;TheBmp->Width ;x ) TheBmp->Canvas->Pixels[x][y]=a[x][y]; } Image1->Canvas->Draw(0,0,TheBmp); 幫我看一下好嗎~~謝謝~~~
isspice
一般會員


發表:23
回覆:12
積分:7
註冊:2004-04-19

發送簡訊給我
#4 引用回覆 回覆 發表時間:2004-04-24 17:49:55 IP:140.125.xxx.xxx 未訂閱
您好~~我剛照你的意思做但是還是沒有東西耶~~且會出錯~~ 訊息是::Assign unsignchar to Tcolor Graphics::TBitmap *TheBmp = new Graphics::TBitmap; Byte a[100][100]={0}; TheBmp->Width = 100; TheBmp->Height = 100; TheBmp->PixelFormat = pf8bit; fill(*a,*a 100*100,25); //將全部設為25 //TheBmp = Image1->Picture->Bitmap; for (int y=0;y< TheBmp->Height;y ) { for (int x=0;TheBmp->Width ;x ) TheBmp->Canvas->Pixels[x][y]=a[x][y]; } Image1->Canvas->Draw(0,0,TheBmp); 幫我看一下好嗎~~謝謝~~~
jim006
一般會員


發表:22
回覆:25
積分:9
註冊:2004-01-14

發送簡訊給我
#5 引用回覆 回覆 發表時間:2004-04-24 18:31:45 IP:218.162.xxx.xxx 未訂閱
Graphics::TBitmap *TheBmp = new Graphics::TBitmap; Byte a[100][100]={0}; TheBmp->Width = 100; TheBmp->Height = 100; Image1->Picture->Assign(TheBmp);    for (int y=0;y< TheBmp->Height;y++) { for (int x=0;xWidth ;x ) TheBmp->Canvas->Pixels[x][y]=a[x][y]; } Image1->Picture->Assign(TheBmp);
arisaka_matsuri
高階會員


發表:25
回覆:205
積分:231
註冊:2003-10-19

發送簡訊給我
#6 引用回覆 回覆 發表時間:2004-04-25 17:02:12 IP:218.166.xxx.xxx 未訂閱
isspice 你好: 用ScanLine的技巧~~
//
// 已經有一陣列的資料
// Byte a[240][320]; 
//
Graphics::TBitmap *TheImage = new Graphics::TBitmap;
TheImage->PixelFormat = pf8bit;
TheImage->Height = 240;
TheImage->Width  = 320;
// 將陣列資料複製到TBitmap物件中
Byte *ptr;
for(int row = 0; row < TheImage->Height; row  )
{
  ptr = (Byte *)TheImage->ScanLine[row];
  for(int col = 0; col < TheImage->Width; col  )
    ptr[col] = a[row][col];
}
// 將bitmap畫在 TImage Image1 上
Image1->Canvas->Draw(0,0,TheImage);
不過,TheImage的PixelFormat設定為8bpp 需要另外產生調色盤,不然顏色會怪怪的喔~
JerryKuo
版主


發表:42
回覆:571
積分:322
註冊:2003-03-10

發送簡訊給我
#7 引用回覆 回覆 發表時間:2004-04-27 11:56:50 IP:61.230.xxx.xxx 未訂閱
引言: 您好~~我剛照你的意思做但是還是沒有東西耶~~且會出錯~~ 訊息是::Assign unsignchar to Tcolor Graphics::TBitmap *TheBmp = new Graphics::TBitmap; Byte a[100][100]={0}; TheBmp->Width = 100; TheBmp->Height = 100; TheBmp->PixelFormat = pf8bit; fill(*a,*a 100*100,25); //將全部設為25 //TheBmp = Image1->Picture->Bitmap; for (int y=0;y< TheBmp->Height;y ) { for (int x=0;TheBmp->Width ;x ) TheBmp->Canvas->Pixels[x][y]=(TColor)RGB(a[x][y],a[x][y],a[x][y]); } Image1->Canvas->Draw(0,0,TheBmp);
你好: 如果你不想使用scanline的話,請修改紅色的部分 因為Pixels[x][y]的資料結構是TColor,直接assign會出錯 ^^ 發表人 - jerrykuo 於 2004/04/27 12:01:13
系統時間:2024-05-11 5:26:19
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!