image reading

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vimal3271@gmail.com

    image reading

    I want to know how to read image files in C.. what are the headers
    that i should include? is there any tutorials regarding this ? pls
    inform me.
  • Richard Heathfield

    #2
    Re: image reading

    vimal3271@gmail .com said:
    I want to know how to read image files in C.. what are the headers
    that i should include?
    C doesn't directly support any particular image format (although one might
    make out a case for XPM), but it's easy enough to open a file using fopen.
    Then comes the fun part - working out which bit of the file means what.
    is there any tutorials regarding this ?
    http://www.wotsit.org has the specs on lots of file formats.

    --
    Richard Heathfield <http://www.cpax.org.uk >
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999

    Comment

    • vippstar@gmail.com

      #3
      Re: image reading

      On Oct 6, 4:18 pm, vimal3...@gmail .com wrote:
      I want to know how to read image files in C.. what are the headers
      that i should include? is there any tutorials regarding this ?
      You can open files with fopen. You can read their data with various
      functions, for example, fgetc, fread.
      The headers that should be included depend on the functions you are
      going to use.
      Any decent C book will help you with all these.
      I recommend K&R2.
      pls inform me.
      pls? Don't you mean please? Type the whole word, please.

      Comment

      • Richard Tobin

        #4
        Re: image reading

        In article <5aa017f4-d1df-4926-802a-81f8a87abd79@c2 2g2000prc.googl egroups.com>,
        <vimal3271@gmai l.comwrote:
        >I want to know how to read image files in C.. what are the headers
        >that i should include? is there any tutorials regarding this ? pls
        >inform me.
        You probably don't want to write this yourself. There are free
        libraries available for the common formats like JPEG and TIFF, and
        they should be fairly portable. Obviously displaying an image is
        system-dependent, but just reading in the data is much less so.

        Start by Googling for libjpeg, libtiff, libpng...

        -- Richard
        --
        Please remember to mention me / in tapes you leave behind.

        Comment

        • viza

          #5
          Re: image reading

          On Mon, 06 Oct 2008 06:18:32 -0700, vimal3271 wrote:
          I want to know how to read image files in C.. what are the headers that
          i should include? is there any tutorials regarding this ? pls inform me.
          Simple:

          libgd http://www.libgd.org

          Powerful:

          libvips http://vips.sf.net

          Comment

          • Richard Heathfield

            #6
            Re: image reading

            vippstar@gmail. com said:
            On Oct 6, 4:18 pm, vimal3...@gmail .com wrote:
            >I want to know how to read image files in C.. what are the headers
            >that i should include? is there any tutorials regarding this ?
            >
            You can open files with fopen. You can read their data with various
            functions, for example, fgetc, fread.
            The headers that should be included depend on the functions you are
            going to use.
            Any decent C book will help you with all these.
            I recommend K&R2.
            Perhaps you could remind me which section of K&R2 deals with image formats?

            --
            Richard Heathfield <http://www.cpax.org.uk >
            Email: -http://www. +rjh@
            Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
            "Usenet is a strange place" - dmr 29 July 1999

            Comment

            • vippstar@gmail.com

              #7
              Re: image reading

              On Oct 6, 6:20 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
              vipps...@gmail. com said:
              >
              On Oct 6, 4:18 pm, vimal3...@gmail .com wrote:
              I want to know how to read image files in C.. what are the headers
              that i should include? is there any tutorials regarding this ?
              >
              You can open files with fopen. You can read their data with various
              functions, for example, fgetc, fread.
              The headers that should be included depend on the functions you are
              going to use.
              Any decent C book will help you with all these.
              I recommend K&R2.
              >
              Perhaps you could remind me which section of K&R2 deals with image formats?
              OP mentioned image files, image files are just files.

              Comment

              • adam majewski

                #8
                Re: image reading

                vimal3271@gmail .com pisze:
                I want to know how to read image files in C.. what are the headers
                that i should include? is there any tutorials regarding this ? pls
                inform me.
                For me the simplest image file is PPM. If you can create file you can
                also read it.

                =============== ===
                #include <stdio.h>
                int main() {
                const int dimx = 800;
                const int dimy = 800;
                int i, j;
                FILE * fp = fopen("first.pp m", "wb"); /* b - tryb binarny */
                fprintf(fp, "P6\n%d %d\n255\n", dimx, dimy);
                for(j=0; j<dimy; ++j){
                for(i=0; i<dimx; ++i){
                static unsigned char color[3];
                color[0]=i % 255; /* red */
                color[1]=j % 255; /* green */
                color[2]=(i*j) % 255; /* blue */
                fwrite(color,1, 3,fp);
                }
                }
                fclose(fp);
                return 0;
                }

                =============== =============== ======


                Look also :




                HTH

                Adam

                Comment

                • Richard Heathfield

                  #9
                  Re: image reading

                  vippstar@gmail. com said:
                  On Oct 6, 6:20 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
                  >vipps...@gmail .com said:
                  >>
                  On Oct 6, 4:18 pm, vimal3...@gmail .com wrote:
                  >I want to know how to read image files in C.. what are the headers
                  >that i should include? is there any tutorials regarding this ?
                  >>
                  You can open files with fopen. You can read their data with various
                  functions, for example, fgetc, fread.
                  The headers that should be included depend on the functions you are
                  going to use.
                  Any decent C book will help you with all these.
                  I recommend K&R2.
                  >>
                  >Perhaps you could remind me which section of K&R2 deals with image
                  >formats?
                  >
                  OP mentioned image files, image files are just files.
                  On one level, yes, that's true - but if he just meant arbitrary files, he'd
                  have said so. He specifically mentioned image files, and it doesn't
                  require a genius to deduce that he wishes to do some kind of image
                  processing (even if it's only display), which means he's going to need to
                  be able to decode image formats. He realises this. I realise this. And I
                  suspect you realise this too. To pretend otherwise is disingenuous.

                  --
                  Richard Heathfield <http://www.cpax.org.uk >
                  Email: -http://www. +rjh@
                  Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
                  "Usenet is a strange place" - dmr 29 July 1999

                  Comment

                  • jellybean stonerfish

                    #10
                    Re: image reading

                    On Mon, 06 Oct 2008 06:18:32 -0700, vimal3271 wrote:
                    I want to know how to read image files in C.. what are the headers that
                    i should include? is there any tutorials regarding this ? pls inform me.
                    Well, it depends on which formats you need to open. Do you just want to
                    read the image files, or be able to display them.

                    You could try "Developer' s Image Library" and write code to use it.



                    Or for more open source image libraries, you could look here.





                    stonerfish

                    Comment

                    • Antoninus Twink

                      #11
                      Re: image reading

                      On 6 Oct 2008 at 16:29, Richard Heathfield wrote:
                      vippstar@gmail. com said:
                      On one level, yes, that's true - but if he just meant arbitrary files, he'd
                      have said so. He specifically mentioned image files, and it doesn't
                      require a genius to deduce that he wishes to do some kind of image
                      processing (even if it's only display), which means he's going to need to
                      be able to decode image formats. He realises this. I realise this. And I
                      suspect you realise this too. To pretend otherwise is disingenuous.
                      Not so much fun when it's someone else playing the
                      deliberate-misunderstandin g game, is it?

                      Comment

                      • vippstar@gmail.com

                        #12
                        Re: image reading

                        On Oct 6, 7:29 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
                        vipps...@gmail. com said:
                        >
                        >
                        >
                        On Oct 6, 6:20 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
                        vipps...@gmail. com said:
                        >
                        On Oct 6, 4:18 pm, vimal3...@gmail .com wrote:
                        I want to know how to read image files in C.. what are the headers
                        that i should include? is there any tutorials regarding this ?
                        >
                        You can open files with fopen. You can read their data with various
                        functions, for example, fgetc, fread.
                        The headers that should be included depend on the functions you are
                        going to use.
                        Any decent C book will help you with all these.
                        I recommend K&R2.
                        >
                        Perhaps you could remind me which section of K&R2 deals with image
                        formats?
                        >
                        OP mentioned image files, image files are just files.
                        >
                        On one level, yes, that's true - but if he just meant arbitrary files, he'd
                        have said so. He specifically mentioned image files, and it doesn't
                        require a genius to deduce that he wishes to do some kind of image
                        processing (even if it's only display), which means he's going to need to
                        be able to decode image formats. He realises this. I realise this. And I
                        suspect you realise this too. To pretend otherwise is disingenuous.
                        I mentioned what's possible within standard C.
                        If someone asks for arrays, I'll reply for C arrays; I don't care if
                        he was obviously asking for something else, ie arrays in computer
                        science et cetera.
                        That's for three reasons

                        1) One who gets replies quite different than what he expected, would
                        stop and think if he's asking in the right newsgroup. (especially
                        since someone would suggest that...)
                        2) One who searches comp.lang.c for arrays won't find replies to CS
                        arrays; he'll find replies for C arrays.
                        3) Replying for CS arrays would be off-topic; Telling him to ask in a
                        CS newsgroup would be misleading to those who search for arrays in
                        this newsgroup.

                        Comment

                        • vippstar@gmail.com

                          #13
                          Re: image reading

                          On Oct 6, 8:09 pm, vipps...@gmail. com wrote:
                          <snip>
                          ie arrays in computer science et cetera.
                          ^^ ^^ ^^^^^^

                          Whoops, that might piss those who know latin well... :-)

                          Comment

                          • Malcolm McLean

                            #14
                            Re: image reading


                            <vimal3271@gmai l.comwrote in message news:
                            >I want to know how to read image files in C.. what are the headers
                            that i should include? is there any tutorials regarding this ? pls
                            inform me.
                            >
                            Basic Algorithms includes chapters on BMP, GIF and JPEG formats. Code is
                            free to download. However it is teaching code - the JPEG decoder won't
                            handle JPEG2 for example.
                            See website for details.

                            --
                            Free games and programming goodies.


                            Comment

                            • Richard Tobin

                              #15
                              Re: image reading

                              In article <7db32fed-2f0f-47e7-b714-a0b0ede69122@d3 1g2000hsg.googl egroups.com>,
                              <vippstar@gmail .comwrote:
                              >ie arrays in computer science et cetera.
                              >Whoops, that might piss those who know latin well... :-)
                              Why?

                              -- Richard
                              --
                              Please remember to mention me / in tapes you leave behind.

                              Comment

                              Working...