Hi, I am supposed to read in a .bmp file and then alter it based on command line arguements.
Examples:
-fromrow x, where x specifies the bottommost row to process
-torow x, 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)
I have been given this code as am example of reading a .bmp file:
I don't even know where to start in terms of altering an image... :/Code:#include <stdio.h> #include <stdlib.h> int main(){ FILE *fp= fopen("sample.bmp", "r+"); if (fp == NULL){ printf("Error"); } int temp=0; //Go to Byte 22 fseek(fp,22,SEEK_SET); //Read byte 22 into an integer variable fread(&temp, sizeof(int), 1, fp); printf("Number of Rows: %d\n", temp); fseek(fp,18,SEEK_SET); fread(&temp, sizeof(int), 1, fp); printf("Number of Columns: %d\n", temp); fseek(fp,10,SEEK_SET); fread(&temp, sizeof(int), 1, fp); printf("Start of Pixels: %d\n", temp); fclose (fp); }
ANY help/advice/linfo/links would be greatly appreciated.
Thank you in advance.



LinkBack URL
About LinkBacks


