Newbie read image help

From: Joe (nospam_at_nospam.com)
Date: 02/04/04


Date: Wed, 4 Feb 2004 00:51:46 +0100

Hi all.

I'm writing a program that is supposed to be able to read an image file from
the harddrive and put all image data into a big matrix (or if not possible,
into an array). I obviously don't know the size of the file in advance, only
the file name.
My question is, how do I do this in C++. All newbie examples I have looked
at are with simple ASCII textfiles ending with a null byte and a for loop
reading one byte or one line per loop. But what I want is to read an entire
binary file _at once_, and put all it's content into memory.
I guess this is no more than 2-3 lines of code, but I just can't find it
myself.
Also, is it possible to choose if I want to store the data in a matrix or an
array, that would be great if I could choose.

Also, is there any (free open source) libraries out there that someone can
recommened for reading an image and with functions for fetching the pixel
data at a certain coordinate, for example:
int pixelvalue=image.getPixel(x,y);
Nice features would be if the library could read jpeg images as well.

Any help and any ideas would be really appreciated.

Thanks in advance.

/Joe



Relevant Pages

  • Re: Problem with a script
    ... a loop there becomes impractical. ... You still have them as uniquely named array indexes... ... writing the code twice will only ... reading your entire code and parsing it in their head, ...
    (comp.lang.php)
  • Re: Problem with a script
    ... Okay, so variables have unique labels, that doesn't mean they still couldn't be handled in a loop. ... You still have them as uniquely named array indexes... ... I believe that for the new guy this code would be readable, and identifying problems should really not be any more difficult with this, plus I think that it actually might save some time to write the actual code from the beginnig, even though it's not at it's final stage, instead of first writing everything spread out, and then rewriting the same code again cleaned. ... If you expect a person to spend an hour reading your entire code and parsing it in their head, you wont get any help and have to solve the problem by yourself. ...
    (comp.lang.php)
  • Re: Problem with a script
    ... a loop there becomes impractical. ... You still have them as uniquely named array indexes... ... writing the code twice will only ... reading your entire code and parsing it in their head, ...
    (comp.lang.php)
  • Re: [regexp] Speaking of the /s modifier...
    ... Sorry, I'm relatively new to programming in general, so I'm not sure what you mean by "sanitizing." ... speaking, while in a "while" loop, the presence or absence of a /s ... No when slurping all lines at once into an array and loop over the array. ... The $/ variable is very interesting for reading multiline records from a file like conventional lines. ...
    (perl.beginners)
  • Re: A Faster/Better way?
    ... compiler and library. ... for each element in the array. ... libraries are back compatible but not forward compatible. ... frontend to convert the implied do loop into the equivalent array ...
    (comp.lang.fortran)