全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:4494
推到 Plurk!
推到 Facebook!

請問:讀取PGM圖檔的問題

尚未結案
cowbjt
一般會員


發表:11
回覆:30
積分:8
註冊:2004-07-16

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-04-10 17:12:40 IP:140.124.xxx.xxx 未訂閱
我們知道在一般的bmp檔,我們可以用 tempPtr=(Byte*)Image1->Picture->Bitmap->ScanLine[y]; 然後,用tempPtr[x*3]、tempPtr[x*3 1]、tempPtr[x*3 2]的方式讀到一個pixel的值 請問一下,PGM檔也是用此方式嗎? 這樣讀到的值似乎怪怪的 不知道有沒有人試過讀取PGM檔的pixel值 謝謝
fnk
高階會員


發表:40
回覆:149
積分:102
註冊:2004-01-02

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-04-14 12:23:51 IP:140.124.xxx.xxx 未訂閱
我從網路上抓下來的PGM檔案格式... 給你參考... 基本上你可能要用讀file的方法..把PGM讀進來... 接著再將PGM裡面有關影像的資料..一個一個填入Image中...    若有問題...再來討論唄..^^    ==========================================================
NAME
     pgm - portable graymap file format    DESCRIPTION
     The portable graymap format is a lowest  common  denominator
     grayscale file format.  The definition is as follows:         - A "magic number" for identifying the  file  type.   A  pgm
       file's magic number is the two characters "P2".         - Whitespace (blanks, TABs, CRs, LFs).         - A width, formatted as ASCII characters in decimal.         - Whitespace.         - A height, again in ASCII decimal.         - Whitespace.         - The maximum gray value, again in ASCII decimal.         - Whitespace.         - Width * height gray values, each in ASCII decimal, between
       0  and  the  specified  maximum  value,  separated by whi-
       tespace, starting at the top-left corner of  the  graymap,
       proceeding  in normal English reading order.  A value of 0
       means black, and the maximum value means white.         - Characters from a "#" to the next end-of-line are  ignored
       (comments).         - No line should be longer than 70 characters.         Here is an example of a small graymap in this format:
     P2
     # feep.pgm
     24 7
     15
     0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
     0  3  3  3  3  0  0  7  7  7  7  0  0 11 11 11 11  0  0 15 15 15 15  0
     0  3  0  0  0  0  0  7  0  0  0  0  0 11  0  0  0  0  0 15  0  0 15  0
     0  3  3  3  0  0  0  7  7  7  0  0  0 11 11 11  0  0  0 15 15 15 15  0
     0  3  0  0  0  0  0  7  0  0  0  0  0 11  0  0  0  0  0 15  0  0  0  0
     0  3  0  0  0  0  0  7  7  7  7  0  0 11 11 11 11  0  0 15  0  0  0  0
     0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0    AUTHOR
     Copyright (C) 1989, 1991 by Jef Poskanzer.
============================================================== =========== 有興趣,就能進步 ===========
cowbjt
一般會員


發表:11
回覆:30
積分:8
註冊:2004-07-16

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-04-16 10:20:19 IP:203.73.xxx.xxx 未訂閱
嗯嗯,謝謝 我原本是想用ScanLine的方式讀值 因為,我怕用Image->Canvas->Pixels[x][y]的方式會很慢 但我實作的結果還可以接受 不知道有沒有測過這二種方法的效率差多少
JerryKuo
版主


發表:42
回覆:571
積分:322
註冊:2003-03-10

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-04-16 10:30:19 IP:220.135.xxx.xxx 未訂閱
引言: 嗯嗯,謝謝 我原本是想用ScanLine的方式讀值 因為,我怕用Image->Canvas->Pixels[x][y]的方式會很慢 但我實作的結果還可以接受 不知道有沒有測過這二種方法的效率差多少
cowbjt你好: 如果只做幾個點,相差不多, 但如果做一整張圖, 則差很多。
julia-zeng
一般會員


發表:0
回覆:1
積分:0
註冊:2005-10-20

發送簡訊給我
#5 引用回覆 回覆 發表時間:2005-11-03 23:26:28 IP:220.136.xxx.xxx 未訂閱
請問用Image->Canvas->Pixels[x][y]的方法讀PGM,讀到的值還是TColor嗎?
系統時間:2024-05-10 9:49:46
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!