会喜欢我的任务之一集思广益一些帮助。我将编写一个程序来处理.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