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

讀RAW DATA遇到問題

答題得分者是:taishyang
ray7797
一般會員


發表:6
回覆:4
積分:2
註冊:2011-10-17

發送簡訊給我
#1 引用回覆 回覆 發表時間:2011-10-17 22:45:29 IP:140.138.xxx.xxx 訂閱

void __fastcall TForm1::Button1Click(TObject *Sender)
{
Byte *ptr;
if(OpenDialog1->Execute())
{
TMemoryStream* bin=new TMemoryStream();
bin->LoadFromFile(OpenDialog1->FileName);
int dwSize=Image1->Height*Image1->Width;
Byte *pixel=new BYTE[dwSize];
bin->Read(pixel, dwSize);
Graphics::TBitmap *bmp = new Graphics::TBitmap();
bmp->PixelFormat=pf24bit;
bmp->Height=Image1->Height;
bmp->Width=Image1->Width;
for(int y=0; y<=Height; y )
{
ptr=(Byte *)bmp->ScanLine[y];
for(int x=0; x<=Width; x )
{
ptr[x*3]=pixel[y*Image1->Width x];
ptr[x*3 1]=pixel[y*Image1->Width x];
ptr[x*3 2]=pixel[y*Image1->Width x];
}
}
Image1->Picture->Assign(bmp);
delete bmp;
delete bin;
}
}

想請問為何在按下BUTTON後

會顯示出錯誤訊息.....'Scan line index out of range'................

是哪裡出了問題呢QQ

編輯記錄
ray7797 重新編輯於 2011-10-17 08:46:55, 註解 無‧
ray7797 重新編輯於 2011-10-17 09:12:52, 註解 無‧
taishyang
站務副站長


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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2011-10-18 10:27:12 IP:114.32.xxx.xxx 訂閱
for(int y=0; y<=Height; y ) 可能超出範圍了
試試
for(int y=0; y
ray7797
一般會員


發表:6
回覆:4
積分:2
註冊:2011-10-17

發送簡訊給我
#3 引用回覆 回覆 發表時間:2011-10-18 11:29:24 IP:140.138.xxx.xxx 訂閱

===================引 用 taishyang 文 章===================
for(int y=0; y<=Height; y ) 可能超出範圍了
試試
for(int y=0; y



有依照您的指點修改過了,不過還是一樣的問題Q_Q

我開的圖片是512x512,RAW data,8bits per pixel

好不解Orz

taishyang
站務副站長


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

發送簡訊給我
#4 引用回覆 回覆 發表時間:2011-10-18 11:41:38 IP:114.32.xxx.xxx 訂閱
for(int y=0; y < Height; y )
你的Height確定是512嗎? 還是Form1的Height?
錯誤訊息表示超出範圍,檢查一下是哪裡超出範圍便能解決 ^^


ray7797
一般會員


發表:6
回覆:4
積分:2
註冊:2011-10-17

發送簡訊給我
#5 引用回覆 回覆 發表時間:2011-10-18 12:04:10 IP:140.138.xxx.xxx 訂閱

===================引 用 taishyang 文 章===================
for(int y=0; y < Height; y )
你的Height確定是512嗎? 還是Form1的Height?
錯誤訊息表示超出範圍,檢查一下是哪裡超出範圍便能解決 ^^

'Scan line index out of range'

錯誤訊息的前面那一段不太懂在表示什麼

Form1的Height有確認過了沒有問題圖片也是都是512x512的Lena.raw ,Lena.bmp


taishyang
站務副站長


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

發送簡訊給我
#6 引用回覆 回覆 發表時間:2011-10-18 12:33:19 IP:114.32.xxx.xxx 訂閱
下載LENA.raw檔後
ftp://core.ring.gr.jp/pub/X/opengroup/R5contrib/wavelet_pic/lena.raw
試試下面的code
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Byte *ptr = NULL;
int h = 512;
int w = 512;
int dwSize = h * w;

TMemoryStream* bin=new TMemoryStream();
bin->LoadFromFile("lena.raw");

Byte *pixel = new BYTE[dwSize];
bin->Read(pixel, dwSize);
Graphics::TBitmap *bmp = new Graphics::TBitmap();
bmp->PixelFormat=pf24bit;
bmp->Height = h;
bmp->Width = w;

for(int y=0; y < h; y ){
ptr=(Byte *)bmp->ScanLine[y];
for(int x=0; x < w; x ){
ptr[x*3] = pixel[y*w x];
ptr[x*3 1] = pixel[y*w x 1];
ptr[x*3 2] = pixel[y*w x 2];
}
}
Image1->Picture->Assign(bmp);
delete bmp;
delete bin;
delete pixel;
}
ray7797
一般會員


發表:6
回覆:4
積分:2
註冊:2011-10-17

發送簡訊給我
#7 引用回覆 回覆 發表時間:2011-10-18 13:34:30 IP:140.138.xxx.xxx 訂閱
 出現了  cannot open file lena.raw

檔案已經下載了

是有需要放到指定位子嗎?

抱歉,剛接觸bcb好陌生...
ray7797
一般會員


發表:6
回覆:4
積分:2
註冊:2011-10-17

發送簡訊給我
#8 引用回覆 回覆 發表時間:2011-10-18 13:56:27 IP:140.138.xxx.xxx 訂閱
 解決問題了!謝謝taishyang老師XD
系統時間:2024-04-27 9:28:46
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!