would appreciate brainstorming 1 of assignments. write program basic point processing of .bmp image. program open .bmp file reading , writing , not change part of header, pixel values in file according command line arguments:
-fromrow x, x specifies bottommost row process -torowx, x specifies topmost row process -fromcol x, x specifies leftmost column process -tocol x, x specifies rightmost column process -op x, x 1 of following: - 1 = threshold image (any pixel value in specifies range on 127 changed 255, , pixel values 127 or less changed 0) - 2 = negative (any pixel value p in specified range changed 255-p) process image data, need make use of following: - each pixel value unsigned char - number of rows in image stored int @ position (byte address) 22 in file - number of columns in image stored int @ position (byte address) 18 in file - position @ pixel data starts int stored @ position (byte address) 10 in file - pixel information stored row row, starting bottommost row in image (row 0) , progressing upwards. within row; pixel information stored left right. padding added end of each row make row length multiple of 4 bytes (if row has 479 columns, there 1 padding @ end of row before next row starts)
i'm bit lost how begin, figure should make struct bitmap first so?
struct bitmap { unsigned int startrow; unsigned int endrow; unsigned int startcol; unsigned int endcol; }
can walk me through need byte addresses assignment references? other brainstorming advice appreciated well. thanks!
you can read raw bytes opening file in binary mode:
file *fid = fopen("blah.bmp", "rb");
you can read amount of data thus:
int num_actually_read = fread(p, sizeof(*p), num_to_read, fid);
where p
pointer buffer. in case, want p
of type uint8_t *
, because you're dealing raw bytes mostly.
alternatively, can jump around in file thus:
fseek(fid, pos, seek_set);
i hope enough going.
Comments
Post a Comment