Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have to make a program to read the R,G,B colour of an image. Please tell me the code for reading an image.
Posted
Updated 2-Dec-16 18:12pm
v2
Comments
Nithin Sundar 30-Jan-11 23:33pm    
We cannot tell you the code. We can only help you if you have problems with your code. Please show some effort and everyone will be happy to help you.
[no name] 31-Jan-11 2:08am    
What format (e.g. jpeg, png, bitmap) is your image stored in?
LaxmikantYadav 31-Jan-11 6:59am    
Plz specify the image file format.

We can't just give you code for this: it will depend on what image type you are trying to read:
.JPG internal format is totally different from .BMP for example.

C does not have the high-level routines to read an image file - you have to read the file format and process it yourself.

Reading the file is easy:
C++
FILE *input;
char get_char;
input = fopen("myimage.bmp", "rb");
while((get_char=fgetc(input))!= EOF)
   {
   ...
   }
fclose(input);
Reads a file a byte at a time.

You will need to Google for the file format, and process it accordingly.
 
Share this answer
 
See here[^] for all the Microsoft support libraries for graphics. You may also need to Google for specifics on some graphics structures.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900