會喜歡我的任務之一集思廣益一些幫助。我將編寫一個程序來處理.bmp圖像的基本點處理。程序將打開.bmp文件進行讀取和寫入,並不會改變頭部的任何部位,但根據命令行參數文件中的像素值:位圖點處理
-fromrow x, where x specifies the bottommost row to process
-torowx, where x specifies the topmost row to process
-fromcol x, where x specifies the leftmost column to process
-tocol x, where x specifies the rightmost column to process
-op x, where x is one of the following:
- 1 = threshold the image (any pixel value in the specifies range over 127 is changed to 255, and pixel values 127 or less is changed to 0)
- 2 = negative (any pixel value p in the specified range is changed to 255-p)
To process image data, you will need to make use of the following:
- each pixel value is an unsigned char
- the number of rows in the image is stored as an int at position (byte address) 22 in the file
- the number of columns in the image is stored as an int at position (byte address) 18 in the file
- the position at which the pixel data starts is an int stored at position (byte address) 10 in the file
- pixel information is stored row by row, starting from the bottommost row in the image (row 0) and progressing upwards. within a row; pixel information is stored left to right. padding is added to the end of each row to make row length a multiple of 4 bytes (if the row has 479 columns, there is one extra padding at the end of the row before the next row starts)
我有點失落至於如何開始,但我想我應該做一個結構位圖首先像這樣?
struct bitmap {
unsigned int startrow;
unsigned int endrow;
unsigned int startcol;
unsigned int endcol;
}
任何人都可以幫助我通過什麼,我需要做的字節地址,該任務引用?任何其他頭腦風暴的建議也將不勝感激。謝謝!
你知道如何打開一個文件?你知道如何從文件中讀取嗎? – 2011-04-29 22:05:42
種。我最後的任務是從文本文件中讀取和解析數據,所以我認爲它會有點類似? 'INT主(INT的argc,字符* argv的[]){ \t INT I; \t FILE * fp; (i = 1; i
raphnguyen
2011-04-29 22:12:09
看到這個問題。你需要知道如何閱讀原始字節,而不是文本。http://stackoverflow.com/questions/5751749/how-can-i-read-bmp-pixel-values-into-an-array – 2011-04-29 22:17:09