Click here to Skip to main content
Sign Up to vote bad
good
See more: CTurbo
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 30 Jan '11 - 17:10
Edited 30 Jan '11 - 20:49

Comments
Nithin Sundar - 30 Jan '11 - 23:33
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.
Thaddeus Jones - 31 Jan '11 - 2:08
What format (e.g. jpeg, png, bitmap) is your image stored in?
Laxmikant_Yadav - 31 Jan '11 - 6:59
Plz specify the image file format.

2 solutions

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:
   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.
  Permalink  
See here[^] for all the Microsoft support libraries for graphics. You may also need to Google for specifics on some graphics structures.
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 239
1 OriginalGriff 173
2 Maciej Los 135
3 Mahesh Bailwal 104
4 Aarti Meswania 98
0 Sergey Alexandrovich Kryukov 10,214
1 OriginalGriff 7,819
2 CPallini 4,181
3 Rohan Leuva 3,522
4 Maciej Los 3,089


Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 31 Jan 2011
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid