c - Convert BMP into grayscale issue -


i started messing around image processing , wanted know if there way make gray scale image without using image processing libraries, know first 3 bits given information on image, format , size, on want make gray scale image
code :

#include <stdio.h> int main(){ file * binary = fopen("c:/arabidopsis3.bmp", "rb"); file * bcopy=fopen("c:/copy.bmp","wb"); int get_char; int i=3; while ((get_char=fgetc(binary))!= eof)  { if(i>3)     {                  doing grayscale process              }     fputc(get_char, bcopy);     i++;   }   fclose(binary);   fclose(bcopy);   return 0;  } 

as can see i`m copying bmp copy.bmp copy.bmp should grayscale. suggestions?

to start, bmp file format has header file gets stripped (not in memory). after header, there region of memory fixed size, there 7 different formats next region is: http://en.wikipedia.org/wiki/bmp_file_format

you'll have determine format, determine how many bytes needed each pixel. you'll need know pixel description format.

all of pretty easy if little research. don't know file format, should able pretty if understand structure.

edit:

well, if know each pixel value located, should able extract them walking along pixel array pointer. instance, if know there 8 pixels in image, , each pixel defined 8 bytes, can walk along pixel array 8 byte pointer placing 8 byte pointer @ beginning pixel array section , xor. don't know how make gray scale; assume rid of color values. such, if first byte describes gray scale, , rest color data, take color data , make sure bits set 0 then.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -