讀一8bit的影像 |
尚未結案
|
Mmmoney
一般會員 發表:9 回覆:19 積分:5 註冊:2007-10-12 發送簡訊給我 |
不好意思
我的問題延伸自這裡: http://delphi.ktop.com.tw/board.php?cid=168&fid=912&tid=90804 依照taishyang大大的指點後,image有顯示影像了 但有圖形縮小且顏色重疊的感覺 我參考其他文章,加入灰階調色盤後code如下: [code cpp] IppiSize roiSize = {W,H}; pBuf0 = ippiMalloc_8u_C1(W,H,&step0); // create buffer0 // fill buffer0 with Jaehne test image ippiImageJaehne_8u_C1R(pBuf0, step0, roiSize); -->這裡是是其他dll產生圖檔的地方 // 定義灰階調色盤結構 typedef struct { TLogPalette lpal; TPaletteEntry dummy[256]; } LogPal; // 建立灰階調色盤 LogPal GrayPalette; GrayPalette.lpal.palVersion = 0x300; GrayPalette.lpal.palNumEntries = 256; for(int Index = 0; Index < 256; Index ) { GrayPalette.lpal.palPalEntry[Index].peRed = (unsigned char)Index; GrayPalette.lpal.palPalEntry[Index].peGreen = (unsigned char)Index; GrayPalette.lpal.palPalEntry[Index].peBlue = (unsigned char)Index; GrayPalette.lpal.palPalEntry[Index].peFlags = (unsigned char)0; } Graphics::TBitmap *pBitmap = new Graphics::TBitmap(); //VCL class must be structed by "new" pBitmap->PixelFormat=pf8bit; //color depth pBitmap->Width=W; pBitmap->Height=H; pBitmap->Palette=CreatePalette(&GrayPalette.lpal); // 建立灰階調色盤 Byte *ptr1; k=0; for(int i = 0; i < H; i ) { ptr1=(Byte*) pBitmap->ScanLine[i]; for(int j = 0; j < W; j ) { ptr1[j*3]=pBuf1[k]; //複製pBuf1(原始影像資料) ptr1[j*3 1]=pBuf1[k]; ptr1[j*3 2]=pBuf1[k]; k ; } } Image->Picture->Bitmap->PixelFormat=pf8bit; Image->Picture->Bitmap->Palette=pBitmap->Palette; Image->Canvas->Draw(0,0,pBitmap); 但是Image沒有任何動靜 Invalidate(); [/code] 附上檔案為處理的影像,但是是從pdf上複製到小畫家的 請問有沒有大大能指點我一下!! ^^ 編輯記錄
Mmmoney 重新編輯於 2007-10-15 14:21:28, 註解 重新上傳的檔案為"原始影像"和"BCB畫出來的影像"‧
|
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
|
Mmmoney
一般會員 發表:9 回覆:19 積分:5 註冊:2007-10-12 發送簡訊給我 |
===================引 用 taishyang 文 章=================== 能否說明一下為什麼你指定pixelformat是8bits pBitmap->PixelFormat=pf8bit; //color depth 回覆: 喔喔..對不起..這裡是原先為了配合unsigned char的型態 處理卻是24bits? ptr1[j*3] = pBuf1[k]; //複製pBuf1(原始影像資料) ptr1[j*3 1] = pBuf1[k]; ptr1[j*3 2] = pBuf1[k]; 那應該是這樣才對..^^ [code cpp] for(int i = 0; i < H; i ) { ptr1=(Byte*) pBitmap->ScanLine[i]; for(int j = 0; j < W; j ) ptr1[j]=pBuf0[k ]; } [/code] |
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
|
Mmmoney
一般會員 發表:9 回覆:19 積分:5 註冊:2007-10-12 發送簡訊給我 |
===================引 用 taishyang 文 章=================== Image->Picture->Bitmap->PixelFormat=pf8bit; Image->Picture->Bitmap->Palette=pBitmap->Palette; Image->Canvas->Draw(0,0,pBitmap); 但是Image沒有任何動靜 Invalidate(); 這段改成 Image1->Picture->Assign(pBitmap); 試試看 ================================================================ taishyang大大你好: 顏色有變成灰階了,影像也能畫出來,但是還是像電視壞掉的畫面 附上開頭記憶體呼叫的函式說明,也許是我搞錯記憶體大小 Malloc Allocates memory aligned to 32-byte boundary. Syntax ippiMalloc_8u_C1(int widthPixels, int heightPixels,int* pStepBytes); 8u表示unsighed char(8 bit) C1表示一個8u (C2表示2個,以此類推..) Parameters widthPixels Width of an image in pixels. heightPixels Height of an image in pixels. pStepBytes Pointer to the distance in bytes between starts of consecutive lines in the image. |
taishyang
站務副站長 發表:377 回覆:5490 積分:4563 註冊:2002-10-08 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |