如何取得BMP格式的Image的解析度 |
答題得分者是:timhuang
|
change.jian
版主 ![]() ![]() ![]() ![]() ![]() 發表:29 回覆:620 積分:439 註冊:2003-06-02 發送簡訊給我 |
|
timhuang
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:78 回覆:1815 積分:1608 註冊:2002-07-15 發送簡訊給我 |
hi, 原則上該屬性應該是存在 bmp 檔中, 而 image 元件裡沒有直接取得 bmp 的圖檔解析度方法, 弟這裡寫個小範例做為讀取 bmp 圖檔中的解析度方法:
function ReadBMPINFO(filename: string):Boolean; var bfh: TBitmapFileHeader; bih: TBitmapInfoHeader; iFileHandle: Integer; iBytesRead: Integer; begin Result := false; iFileHandle := FileOpen(filename, fmOpenRead); FileSeek(iFileHandle,0,0); iBytesRead := FileRead(iFileHandle, bfh, sizeof(bfh)); if iBytesRead<>sizeof(bfh) then exit; iBytesRead := FileRead(iFileHandle, bih, sizeof(bih)); if iBytesRead<>sizeof(bih) then exit; FileClose(iFileHandle); Result := true; ShowMessage(Format('Width * Height is %d * %d',[bih.biWidth, bih.biHeight])); ShowMessage(Format('Pixel Per Meter is %d * %d',[bih.biXPelsPerMeter, bih.biYPelsPerMeter])); ShowMessage(Format('Pixel Per Meter is %f * %f',[bih.biXPelsPerMeter / 100 *2.54, bih.biYPelsPerMeter / 100 *2.54])); end;另外可以參考這篇 bmp 的檔案格式: http://140.126.11.200/dalton/course/Ip/Handout/BMP.doc |
change.jian
版主 ![]() ![]() ![]() ![]() ![]() 發表:29 回覆:620 積分:439 註冊:2003-06-02 發送簡訊給我 |
|
change.jian
版主 ![]() ![]() ![]() ![]() ![]() 發表:29 回覆:620 積分:439 註冊:2003-06-02 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |