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

如何讀取BMP檔頭

答題得分者是:frankfang
kwobar
一般會員


發表:1
回覆:0
積分:0
註冊:2006-07-11

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-09-26 20:52:26 IP:140.115.xxx.xxx 訂閱
各位大大

請問一下如何不使用BCB6.0的內部元件,讀取BMP的檔頭資料並顯示
看了很多大大的文章,還是無法了解
謝謝
syntax
尊榮會員


發表:26
回覆:1139
積分:1258
註冊:2002-04-23

發送簡訊給我
#2 引用回覆 回覆 發表時間:2008-10-23 15:17:11 IP:118.231.xxx.xxx 訂閱
不使用 ?

那用 FileOpen API 吧!

===================引 用 kwobar 文 章===================
各位大大

請問一下如何不使用BCB6.0的內部元件,讀取BMP的檔頭資料並顯示
看了很多大大的文章,還是無法了解
謝謝
frankfang
一般會員


發表:0
回覆:2
積分:5
註冊:2006-08-25

發送簡訊給我
#3 引用回覆 回覆 發表時間:2008-11-06 00:52:24 IP:203.70.xxx.xxx 訂閱
參考 en.wikipedia.org/wiki/BMP_file_format 就可以了

void __fastcall TMainForm::ListBitmapInfo( void )
{
TFileStream* fs = new TFileStream( OpenDialog1->FileName, fmOpenRead );

AnsiString str;
ListBox1->Clear();

str.printf( "identifier: 0xX ", ReadInt16(fs) );
ListBox1->Items->Add( str );
str.printf( "file size: %d ", ReadInt32(fs) );
ListBox1->Items->Add( str );
str.printf( "reserved: %d ", ReadInt32(fs) );
ListBox1->Items->Add( str );
str.printf( "bmp data offset: %d ", ReadInt32(fs) );
ListBox1->Items->Add( str );
str.printf( "bmp header size: %d ", ReadInt32(fs) );
ListBox1->Items->Add( str );
str.printf( "width: %d ", ReadInt32(fs) );
ListBox1->Items->Add( str );
str.printf( "height: %d ", ReadInt32(fs) );
ListBox1->Items->Add( str );
str.printf( "planes: %d ", ReadInt16(fs) );
ListBox1->Items->Add( str );
str.printf( "bits/pixel: %d ", ReadInt16(fs) );
ListBox1->Items->Add( str );
str.printf( "compression: %d ", ReadInt32(fs) );
ListBox1->Items->Add( str );
str.printf( "bmp data size: %d ", ReadInt32(fs) );
ListBox1->Items->Add( str );
str.printf( "h-resolution: %d ", ReadInt32(fs) );
ListBox1->Items->Add( str );
str.printf( "v-resolution: %d ", ReadInt32(fs) );
ListBox1->Items->Add( str );
str.printf( "used colors: %d ", ReadInt32(fs) );
ListBox1->Items->Add( str );
str.printf( "important colors: %d ", ReadInt32(fs) );
ListBox1->Items->Add( str );
str.printf( "palette: 0xX ", ReadInt32(fs) );
ListBox1->Items->Add( str );

delete fs;
}
//---------------------------------------------------------------------------
unsigned short __fastcall TMainForm::ReadInt16( TStream* s )
{
unsigned short x;
s->Read( &x, sizeof(unsigned short) );
return x;
}
//---------------------------------------------------------------------------
unsigned int __fastcall TMainForm::ReadInt32( TStream* s )
{
unsigned int x;
s->Read( &x, sizeof(unsigned int) );
return x;
}
//---------------------------------------------------------------------------
編輯記錄
frankfang 重新編輯於 2008-11-06 00:56:40, 註解 無‧
系統時間:2024-05-20 10:03:36
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!