請問TBitmap的問題~謝謝 |
尚未結案
|
isspice
一般會員 發表:23 回覆:12 積分:7 註冊:2004-04-19 發送簡訊給我 |
程式如下
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 發送簡訊給我 |
|
isspice
一般會員 發表:23 回覆:12 積分:7 註冊:2004-04-19 發送簡訊給我 |
您好~~我剛照你的意思做但是還是沒有東西耶~~且會出錯~~
訊息是::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 發送簡訊給我 |
您好~~我剛照你的意思做但是還是沒有東西耶~~且會出錯~~
訊息是::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 發送簡訊給我 |
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;x
|
arisaka_matsuri
高階會員 發表:25 回覆:205 積分:231 註冊:2003-10-19 發送簡訊給我 |
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 發送簡訊給我 |
引言: 您好~~我剛照你的意思做但是還是沒有東西耶~~且會出錯~~ 訊息是::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 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |